Created
September 15, 2014 14:25
-
-
Save YusefOuda/17a37b0ff8d855965562 to your computer and use it in GitHub Desktop.
Presents
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
class Presents | |
def self.guess_gifts(wishlist, presents) | |
guess = [] | |
presents.each do |present| | |
wishlist.each do |wish| | |
if (wish.values - present.values).size == 1 | |
guess.push(wish[:name]) | |
end | |
end | |
end | |
guess | |
end | |
end | |
# wishlist = [ | |
# {:name => "mini puzzle", :size => "small", :clatters => "yes", :weight => "light"}, | |
# {:name => "toy car", :size => "medium", :clatters => "a bit", :weight => "medium"}, | |
# {:name => "card game", :size => "small", :clatters => "no", :weight => "light"} | |
# ] | |
# presents = [ | |
# {:size => "medium", :clatters => "a bit", :weight => "medium"}, | |
# {:size => "small", :clatters => "yes", :weight => "light"} | |
# ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment