Skip to content

Instantly share code, notes, and snippets.

@dfriedm
Forked from jeffreybaird/gist:6125515
Created August 1, 2013 15:50
Show Gist options
  • Save dfriedm/6132636 to your computer and use it in GitHub Desktop.
Save dfriedm/6132636 to your computer and use it in GitHub Desktop.

###Hello Review Session!

Below I have included a fairly complex hash called 'us_government' the following questions will be about going through this hash. Write the code that answers each of the questions below.

  1. Return an Array of of the names of all the Supreme Court Justices
  2. access the hash with the name attribute "Senator 18"
  3. Print out the names of all the Representatives to the console
  4. Return an array with the names of all members of the government
  5. Remove "Senator 6" from the hash
  6. Add "Representive 20" to the house of representatives
  7. make the Supreme Court members an array of strings instead of an array of hashes
  8. Add the cabinet, with all it's members to the executive branch
  9. Add a favorite color for all house representatives
  10. Give each hash in every ":Member" array a "children" key that has a value with an array with a random number of kid hashes(no more than 10). Give them arbitrary names like "Kid 1." ex. {:name => "Kid 6"}
  11. Replace A Supreme Court Justice of your choice with "Super Man"
  12. Return three, seperate hashes, one for each branch of the governmnet
us_government = {
       :branches =>
        [
          {:name => "Judicial", :organizations =>
            [{:name => "Supreme Court", :Members =>
              [{:name => "John G. Roberts, Jr"},
               {:name => "Antonin Scalia"},
               {:name => "Anthony M. Kennedy"},
               {:name => "Ruth Bader Ginsburg"},
               {:name => "Stephen G. Breyer"},
               {:name => "Samuel Anthony Alito"},
               {:name => "Sonia Sotomayor"},
               {:name => "Elena Kagan"},
               {:name => "Sonia Sotomayor"},
               {:name => "Clarence Thomas"}
              ]
             }
           ]
          },
          {:name => "Executive", :organizations =>
            [{:name => "President", :Members =>
              [{:name => "Barack Obama"}]
             },
             {:name => "Vice President", :Members =>
              [{:name => "Joesph Biden"}]
             }
           ]
          },
          {:name => "Legislative", :organizations =>
            [{:name => "Senate", :Members =>
              [{:name => "Senator 1"},
               {:name => "Senator 2"},
               {:name => "Senator 3"},
               {:name => "Senator 4"},
               {:name => "Senator 5"},
               {:name => "Senator 6"},
               {:name => "Senator 7"},
               {:name => "Senator 8"},
               {:name => "Senator 9"},
               {:name => "Senator 10"},
               {:name => "Senator 11"},
               {:name => "Senator 12"},
               {:name => "Senator 13"},
               {:name => "Senator 14"},
               {:name => "Senator 15"},
               {:name => "Senator 16"},
               {:name => "Senator 17"},
               {:name => "Senator 18"},
               {:name => "Senator 19"}
              ]
             },
             {:name => "House of Representatives", :Members =>
              [{:name => "Representative 1"},
               {:name => "Representative 2"},
               {:name => "Representative 3"},
               {:name => "Representative 4"},
               {:name => "Representative 5"},
               {:name => "Representative 6"},
               {:name => "Representative 7"},
               {:name => "Representative 8"},
               {:name => "Representative 9"},
               {:name => "Representative 10"},
               {:name => "Representative 11"},
               {:name => "Representative 12"},
               {:name => "Representative 13"},
               {:name => "Representative 14"},
               {:name => "Representative 15"},
               {:name => "Representative 16"},
               {:name => "Representative 17"},
               {:name => "Representative 18"},
               {:name => "Representative 19"}]
             }
           ]
          }
        ]
      }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment