Skip to content

Instantly share code, notes, and snippets.

@seanhandley
Created November 14, 2015 21:36
Show Gist options
  • Save seanhandley/1e4b316d69cc58972df9 to your computer and use it in GitHub Desktop.
Save seanhandley/1e4b316d69cc58972df9 to your computer and use it in GitHub Desktop.
Einstein 4: The Implies Method
def implies?(set_a, val_a, set_b, val_b)
(0..4).any? do |i|
set_a[i] == val_a &&
set_b[i] == val_b
end
end
# The German lives in the third house (position 2)
nationalities = [:swedish, :british, :german, :norwegian, :danish]
# The third house' occupant smokes Prince (position 2)
cigars = [:blends, :pall_mall, :prince, :bluemasters, :dunhill]
implies?(nationalities , :german, cigars, :prince)
# => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment