Advertisement
Guest User

Loader.rb

a guest
Jun 9th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.18 KB | None | 0 0
  1. @r, @a = nil
  2.  
  3. def P(y, x)
  4.     y - ~y << x
  5. end
  6.  
  7. def Z(x)
  8.     @r = x%2 == 0 ? 1+Z(x/2) : 0
  9. end
  10.  
  11. def L(x)
  12.     x / 2 >> Z(x)
  13. end
  14.  
  15. def S(v, y, c, t)
  16.     f, x = L(t), @r
  17.     x = @r
  18.    
  19.     unless f-2 == 0
  20.         if f > 2
  21.             unless f - v == 0
  22.                 w = f > v ? 1 : 0
  23.                 t - w*c
  24.             else
  25.                 y
  26.             end
  27.         else
  28.             P(f, P(S(v, y, c, L(x)), S(v+2, t = S(4, 13, -4, y), c, Z(x))))
  29.         end
  30.     else
  31.         A(S(v, y, c, L(x)), S(v, y, c, Z(x)))
  32.     end
  33. end
  34.  
  35. def A(y, x)
  36.     unless L(y)-1 == 0
  37.         5 << P(y, x)
  38.     else
  39.         S(4, x, 4, Z(@r))
  40.     end
  41. end
  42.  
  43. def D(x)
  44.     c, t, u, f, d = 0, 7, 14
  45.     D(x-1) if x > 0
  46.     while (x /= 2).odd?
  47.         d = L L D x
  48.         f, x = L(@r), L(@r)
  49.         if c - @r == 0 and L(u) == 0 and L(@r) - f == 0
  50.             if (x /= 2).odd?
  51.                 u = S(4, d, 4, @r)
  52.                 t = A(t, d)
  53.             end
  54.             if f/2 & (x /= 2) != 0
  55.                 c = P(d, c)
  56.                 t = S(4, 13, -4, t)
  57.                 u = S(4, 13, -4, u)
  58.             end
  59.         end
  60.         if c != 0 and (x /= 2).odd?
  61.             w = ~u&2 | (x/=2)%2
  62.             if w != 0
  63.                 u = 1 << P(L(c), u)
  64.                 w = P(L(c), t)
  65.             end
  66.             c = @r
  67.             t = P(w, c)
  68.         end
  69.         if (u/2).odd? and (x /= 2).odd?
  70.             c = P(t, c)
  71.             u = S(4, 13, -4, t)
  72.             t = 9
  73.         end
  74.         D(x-1) if x > 0
  75.     end
  76.     @a = P(P(t, P(u, P(x, c))), @a)
  77. end
  78.  
  79. #puts D D D D D 99
  80. D 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement