Created
October 14, 2013 15:06
-
-
Save ahimmelstoss/6977141 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
pigeon_data = { | |
:color => { | |
:purple => ["Theo", "Peter Jr.", "Lucky"], | |
:grey => ["Theo", "Peter Jr.", "Ms .K"], | |
:white => ["Queenie", "Andrew", "Ms .K", "Alex"], | |
:brown => ["Queenie", "Alex"] | |
}, | |
:gender => { | |
:male => ["Alex", "Theo", "Peter Jr.", "Andrew", "Lucky"], | |
:female => ["Queenie", "Ms .K"] | |
}, | |
:lives => { | |
"Subway" => ["Theo", "Queenie"], | |
"Central Park" => ["Alex", "Ms .K", "Lucky"], | |
"Library" => ["Peter Jr."], | |
"City Hall" => ["Andrew"] | |
} | |
} | |
pigeon_list = {} | |
pigeon_data.each do |property, value_hash| | |
value_hash.each do |value, bird_names| | |
bird_names.each do |name| | |
pigeon_list[name] ||= {} | |
pigeon_list[name][property] ||= [] | |
pigeon_list[name][property] << value.to_s | |
end | |
end | |
end | |
# pigeon_list = { | |
# "Theo" => { | |
# :color => ["purple", "grey"], | |
# :gender => "male", | |
# :lives => "Subway" | |
# }, | |
# "Peter Jr." => { | |
# :color => ["purple", "grey"], | |
# :gender => "male", | |
# :lives => "Library" | |
# }, | |
# "Lucky" => { | |
# :color => ["purple"], | |
# :gender => "male", | |
# :lives => "City Hall" | |
# }, | |
# "Ms .K" => { | |
# :color => ["grey", "white"], | |
# :gender => "female", | |
# :lives => "Central Park" | |
# }, | |
# "Queenie" => { | |
# :color => ["white", "brown"], | |
# :gender => "female", | |
# :lives => "Subway" | |
# }, | |
# "Andrew" => { | |
# :color => ["white"], | |
# :gender => "male", | |
# :lives => "Central Park" | |
# }, | |
# "Alex" => { | |
# :color => ["white", "brown"], | |
# :gender => "male", | |
# :lives => "Central Park" | |
# } | |
# } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment