Last active
November 15, 2015 09:39
-
-
Save seanhandley/cdc4e623ff79ed232052 to your computer and use it in GitHub Desktop.
Einstein 9: Iterating
This file contains 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
[: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| | |
next unless nationalities[0] == :norwegian | |
next unless drinks[2] == :milk | |
next unless implies?(nationalities, :british, colors, :red) | |
next unless implies?(nationalities, :swedish, pets, :dogs) | |
next unless implies?(cigars, :pall_mall, pets, :birds) | |
next unless implies?(nationalities , :german, cigars, :prince) | |
next unless implies?(colors, :yellow, cigars, :dunhill) | |
next unless implies?(cigars, :bluemasters, drinks, :beer) | |
next unless implies?(colors, :green, drinks, :coffee) | |
next unless implies?(nationalities, :danish, drinks, :tea) | |
next unless left_of?(colors, :green, colors, :white) | |
next unless next_to?(nationalities, :norwegian, colors, :blue) | |
next unless next_to?(pets, :horses, cigars, :dunhill) | |
next unless next_to?(cigars, :blends, drinks, :water) | |
next unless next_to?(cigars, :blends, pets, :cats) | |
puts [colors, nationalities, pets, drinks, cigars].inspect | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment