Created
March 18, 2015 17:28
-
-
Save tmountain/1d849eba7bddf35f0ae2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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