Skip to content

Instantly share code, notes, and snippets.

@FifthSurprise
Created June 14, 2014 20:18
Show Gist options
  • Save FifthSurprise/411048ac550b6d918f13 to your computer and use it in GitHub Desktop.
Save FifthSurprise/411048ac550b6d918f13 to your computer and use it in GitHub Desktop.
Ruby005 Pigeon Solution
# Write your code here!
require 'pry'
def nyc_pigeon_organizer(pigeon_data)
result = {}
#going through the list of all the attributes
pigeon_data.each do |attributetype, attributelist|
attributelist.each do |attribute, pigeonlist|
pigeonlist.each do | pigeonname|
result[pigeonname]={} unless(result[pigeonname]) #add pigeon if not added before
if(attributetype == :color)
if (result[pigeonname][attributetype].nil?)
result[pigeonname][attributetype] = []
end
result[pigeonname][attributetype] << attribute.to_s
else
result[pigeonname][attributetype] = attribute.to_s
end
end
end
end
result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment