Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @r, @a = nil
- def P(y, x)
- y - ~y << x
- end
- def Z(x)
- @r = x%2 == 0 ? 1+Z(x/2) : 0
- end
- def L(x)
- x / 2 >> Z(x)
- end
- def S(v, y, c, t)
- f, x = L(t), @r
- x = @r
- unless f-2 == 0
- if f > 2
- unless f - v == 0
- w = f > v ? 1 : 0
- t - w*c
- else
- y
- end
- else
- P(f, P(S(v, y, c, L(x)), S(v+2, t = S(4, 13, -4, y), c, Z(x))))
- end
- else
- A(S(v, y, c, L(x)), S(v, y, c, Z(x)))
- end
- end
- def A(y, x)
- unless L(y)-1 == 0
- 5 << P(y, x)
- else
- S(4, x, 4, Z(@r))
- end
- end
- def D(x)
- c, t, u, f, d = 0, 7, 14
- D(x-1) if x > 0
- while (x /= 2).odd?
- d = L L D x
- f, x = L(@r), L(@r)
- if c - @r == 0 and L(u) == 0 and L(@r) - f == 0
- if (x /= 2).odd?
- u = S(4, d, 4, @r)
- t = A(t, d)
- end
- if f/2 & (x /= 2) != 0
- c = P(d, c)
- t = S(4, 13, -4, t)
- u = S(4, 13, -4, u)
- end
- end
- if c != 0 and (x /= 2).odd?
- w = ~u&2 | (x/=2)%2
- if w != 0
- u = 1 << P(L(c), u)
- w = P(L(c), t)
- end
- c = @r
- t = P(w, c)
- end
- if (u/2).odd? and (x /= 2).odd?
- c = P(t, c)
- u = S(4, 13, -4, t)
- t = 9
- end
- D(x-1) if x > 0
- end
- @a = P(P(t, P(u, P(x, c))), @a)
- end
- #puts D D D D D 99
- D 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement