Skip to content

Instantly share code, notes, and snippets.

@YusefOuda
Created September 15, 2014 14:25
Show Gist options
  • Save YusefOuda/17a37b0ff8d855965562 to your computer and use it in GitHub Desktop.
Save YusefOuda/17a37b0ff8d855965562 to your computer and use it in GitHub Desktop.
Presents
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