Last active
December 28, 2015 21:39
-
-
Save ashleygwilliams/7566606 to your computer and use it in GitHub Desktop.
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
# Hashketball Nests | |
# | |
# Great news! You're going to an NBA game! The only catch is that you've been | |
# volunteered to analyze stats at the game. | |
# The stats you are given look like this: | |
game = { | |
teams: [{ | |
name: 'Lakers', | |
colors: ['purple', 'gold'], | |
players: [ | |
{ | |
name: 'Lebron', | |
number: 22, | |
shoe_size: 12, | |
stats: { | |
points: 20, | |
rebounds: 5, | |
assists: 2, | |
steals: 4, | |
blocks: 10, | |
slam_dunks: 3 | |
} | |
}, | |
{ | |
name: 'Karl', | |
number: 17, | |
shoe_size: 8, | |
stats: { | |
points: 20, | |
rebounds: 1, | |
assists: 7, | |
steals: 4, | |
blocks: 5, | |
slam_dunks: 2 | |
} | |
}, | |
{ | |
name: 'Larry', | |
number: 7, | |
shoe_size: 11, | |
stats: { | |
points: 2, | |
rebounds: 9, | |
assists: 21, | |
steals: 14, | |
blocks: 1, | |
slam_dunks: 2 | |
} | |
}, | |
{ | |
name: 'Johnny', | |
number: 2, | |
shoe_size: 13, | |
stats: { | |
points: 5, | |
rebounds: 8, | |
assists: 1, | |
steals: 1, | |
blocks: 3, | |
slam_dunks: 2 | |
} | |
}, | |
{ | |
name: 'Manute', | |
number: 22, | |
shoe_size: 12, | |
stats: { | |
points: 20, | |
rebounds: 5, | |
assists: 2, | |
steals: 4, | |
blocks: 10, | |
slam_dunks: 3 | |
} | |
} | |
] | |
}, | |
{ | |
name: 'Bulls', | |
colors: ['red', 'black'], | |
players: [ | |
{ | |
name: 'Michael', | |
number: 23, | |
shoe_size: 12, | |
stats: { | |
points: 50, | |
rebounds: 2, | |
assists: 5, | |
steals: 2, | |
blocks: 11, | |
slam_dunks: 10 | |
} | |
}, | |
{ | |
name: 'Superkalifragalistic', | |
number: 2, | |
shoe_size: 11, | |
stats: { | |
points: 10, | |
rebounds: 2, | |
assists: 12, | |
steals: 24, | |
blocks: 7, | |
slam_dunks: 2 | |
} | |
}, | |
{ | |
name: 'Cameron', | |
number: 12, | |
shoe_size: 1, | |
stats: { | |
points: 2, | |
rebounds: 15, | |
assists: 2, | |
steals: 3, | |
blocks: 11, | |
slam_dunks: 1 | |
} | |
}, | |
{ | |
name: 'Mike', | |
number: 8, | |
shoe_size: 10, | |
stats: { | |
points: 2, | |
rebounds: 15, | |
assists: 2, | |
steals: 3, | |
blocks: 7, | |
slam_dunks: 2 | |
} | |
}, | |
{ | |
name: 'Cameron', | |
number: 12, | |
shoe_size: 1, | |
stats: { | |
points: 5, | |
rebounds: 1, | |
assists: 3, | |
steals: 8, | |
blocks: 1, | |
slam_dunks: 3 | |
} | |
}, | |
{ | |
name: 'Tom', | |
number: 7, | |
shoe_size: 1, | |
stats: { | |
points: 5, | |
rebounds: 2, | |
assists: 3, | |
steals: 8, | |
blocks: 1, | |
slam_dunks: 6 | |
} | |
} | |
] | |
} | |
] | |
} | |
# Using the power of Ruby, and the Hashes above, answer the following questions: | |
# Return the number of points scored for any player: | |
# | |
# Return the shoe size for any player: | |
# | |
#e.g. => 12 | |
# Return both colors for any team: | |
# | |
#e.g. => ['purple', 'gold'] | |
# Return both teams names: | |
# | |
# Return all the player numbers for a team: | |
# | |
# Return all the stats for a player: | |
#=> e.g. {:points=>50, :rebounds=>2, :assists=>5, :steals=>2, :blocks=>11, :slam_dunks=>10} | |
# Return the rebounds for the player with the largest shoe size | |
# | |
#e.g. => 8 | |
# Bonus Questions: define methods to return the answer to the following questions: | |
# Which player has the most points? | |
# | |
# Which team has the most points? | |
# | |
# Which player has the longest name? | |
# | |
# Super Bonus: | |
# Write a method that returns true if the player with the longest name had the most steals: | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment