Skip to content

Instantly share code, notes, and snippets.

@vznvzn
Created September 27, 2015 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vznvzn/d60f90fdb5a8a68dabc8 to your computer and use it in GitHub Desktop.
Save vznvzn/d60f90fdb5a8a68dabc8 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby1.8
c = 1000
1000.times \
{
n = rand(2 ** c)
n1s = (n * 3).to_s(2)
x = rand(c / 2)
n2s = ((n >> x) * 3).to_s(2)
# p(n1s)
# p(n2s)
y = 0
y += 1 while (y < n2s.length && n1s[y, 1] == n2s[y, 1])
puts([x, c - y].join("\t"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment