Created
June 14, 2014 20:18
-
-
Save FifthSurprise/411048ac550b6d918f13 to your computer and use it in GitHub Desktop.
Ruby005 Pigeon Solution
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
# 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