Skip to content

Instantly share code, notes, and snippets.

@tmountain
Created March 18, 2015 17:28
Show Gist options
  • Save tmountain/1d849eba7bddf35f0ae2 to your computer and use it in GitHub Desktop.
Save tmountain/1d849eba7bddf35f0ae2 to your computer and use it in GitHub Desktop.
def gen_keys(start, offset, count)
[start] + (1..count).to_a.map {|idx| start+offset*idx}
end
seen = {}
start_pos = (1..16).to_a
test_count = 1_000_000
loop do
puts "starting positions #{start_pos.inspect}"
next_start_pos = []
start_pos.each do |x|
keys = gen_keys(x, 16, test_count)
next_start_pos << keys[-1]
keys.each do |j|
if seen.has_key?(j)
puts "FAIL: collission #{j}"
exit
end
seen[j] = true
end
end
seen = {}
start_pos = next_start_pos
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment