Skip to content

Instantly share code, notes, and snippets.

@seanhandley
Last active November 14, 2015 21:09
Show Gist options
  • Save seanhandley/6a15c51431080612f2ec to your computer and use it in GitHub Desktop.
Save seanhandley/6a15c51431080612f2ec to your computer and use it in GitHub Desktop.
Einstein 2: Nesting the loops
[:white, :yellow, :blue, :red, :green].permutation.each do |colors|
[:german, :swedish, :british, :norwegian, :danish,].permutation.each do |nationalities|
[:birds, :cats, :horses, :fish, :dogs].permutation.each do |pets|
[:beer, :water, :tea, :milk, :coffee].permutation.each do |drinks|
[:blends, :pall_mall, :prince, :bluemasters, :dunhill].permutation.each do |cigars|
# ...
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment