Menu

Ruby Pigeondata Color Purple Theo Peter Jr Lucky Grey Theo Peter Jr Ms K White Queenie And Q43892326

RUBY!

  1. pigeon_data = {
  2. :color => {
  3. :purple => [“Theo”, “Peter Jr.”, “Lucky”],
  4. :grey => [“Theo”, “Peter Jr.”, “Ms. K”],
  5. :white => [“Queenie”, “Andrew”, “Ms. K”, “Alex”],
  6. :brown => [“Queenie”, “Alex”]
  7. },
  8. :gender => {
  9. :male => [“Alex”, “Theo”, “Peter Jr.”, “Andrew”,”Lucky”],
  10. :female => [“Queenie”, “Ms. K”]
  11. },
  12. :lives => {
  13. “Subway” => [“Theo”, “Queenie”],
  14. “Central Park” => [“Alex”, “Ms. K”, “Lucky”],
  15. “Library” => [“Peter Jr.”],
  16. “City Hall” => [“Andrew”]
  17. }
  18. }

The data above is organized by attributes – :color, :gender, and:lives, each a hash. Within these hashes are arrays of pigeonnames.

We want this data, but in a different structure. Rather thansorting by attributes, your task is to create a hash wherepigeon names are the keys, with each name pointing to ahash of their attributes.

Expert Answer


Answer to RUBY! pigeon_data = { :color => { :purple => [“Theo”, “Peter Jr.”, “Lucky”], :grey => [“Theo”, “Peter Jr.”, “Ms. K”], :…

OR