Last active
August 29, 2015 14:16
-
-
Save jamiecook/63e999e85be78e42e840 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
ULONG_MAX = 4294967295 | |
zones = (1..5).to_a | |
times = [1212, 1213, 1214, 1215, | |
1312, 1313, 1314, 1315, | |
1412, 1413, 1414, 1415, | |
1512, 1513, 1514, 1515] | |
purposes = (1001..1060).to_a | |
num_cars = [0,1,2,3] | |
seeds = zones.flat_map { |z| | |
times.flat_map { |t| | |
purposes.flat_map { |purp| | |
num_cars.map { |nc| | |
(42 * z * ("%4d%4d%1d" % [t,purp,nc]).to_i) % ULONG_MAX | |
} | |
} | |
} | |
} | |
a,b = [seeds.uniq.size, seeds.size] | |
p [a,b,a.to_f/b] | |
# It appears that 500 zones is enough to get a feel for the collisions | |
# z = 1..5 => [19200, 19200, 1.0] | |
# z = 1..500 => [1918490, 1920000, 0.9992135416666666] | |
# z = 1..5000 => [19035347, 19200000, 0.9914243229166667] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment