Skip to content

Instantly share code, notes, and snippets.

@itzsaga
Created March 10, 2017 04:32
Show Gist options
  • Save itzsaga/da4992da6bcf05420a3b565d15df0c01 to your computer and use it in GitHub Desktop.
Save itzsaga/da4992da6bcf05420a3b565d15df0c01 to your computer and use it in GitHub Desktop.
# given that holiday_hash looks like this:
# {
# :winter => {
# :christmas => ["Lights", "Wreath"],
# :new_years => ["Party Hats"]
# },
# :summer => {
# :fourth_of_july => ["Fireworks", "BBQ"]
# },
# :fall => {
# :thanksgiving => ["Turkey"]
# },
# :spring => {
# :memorial_day => ["BBQ"]
# }
# }
def all_supplies_in_holidays(holiday_hash)
# iterate through holiday_hash and print items such that your readout resembles:
# Winter:
# Christmas: Lights, Wreath
# New Years: Party Hats
# Summer:
# Fourth Of July: Fireworks, BBQ
# etc.
holiday_hash.each do |season, holiday|
puts "#{season.to_s.capitalize}:"
holiday.each do |holiday_name, supplies|
puts " #{holiday_name.to_s.split("_").collect {|split_holiday_name| split_holiday_name.capitalize}.join(" ")}: #{supplies.join(", ")}"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment