Skip to content

Instantly share code, notes, and snippets.

@cboursnell
Created April 25, 2014 16:19
Show Gist options
  • Save cboursnell/011edf5c2aed2c65dba9 to your computer and use it in GitHub Desktop.
Save cboursnell/011edf5c2aed2c65dba9 to your computer and use it in GitHub Desktop.
@ans=[]
def combo(index)
n = @parameters.size
(0..(n-1)).each do |p|
r = 1
@parameters.keys[(p+1)..(n-1)].each do |k|
r *= @parameters[k].size
end
@ans << index/r
index = index % r
end
end
600_000.times do |i|
@ans=[]
hash={}
combo(i)
@ans.each_with_index do |p,i|
#puts "p=#{p}, i=#{i}"
a = @parameters.keys[i]
hash[a] = @parameters[a][p]
end
# p hash
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment