Answered step by step
Verified Expert Solution
Question
1 Approved Answer
RUBY! pigeon_data = { :color => { :purple => [Theo, Peter Jr., Lucky], :grey => [Theo, Peter Jr., Ms. K], :white => [Queenie, Andrew, Ms.
RUBY!
- 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"]
- }
- }
The data above is organized by attributes - :color, :gender, and :lives, each a hash. Within these hashes are arrays of pigeon names.
We want this data, but in a different structure. Rather than sorting by attributes, your task is to create a hash where pigeon names are the keys, with each name pointing to a hash of their attributes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started