Created
October 1, 2013 04:56
-
-
Save manleyhimself/6774036 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
| teams = { | |
| thebest: { | |
| colors: ["orange","purple"], | |
| players:{ | |
| don: { | |
| number: 1, shoe_size: 9, points: 5, rebounds: 6, assists: 7, steals: 8, blocks: 9, slam_dunks: 10 | |
| }, | |
| jon: { | |
| number: 2, shoe_size: 8, points: 6, rebounds: 7, assists: 8, steals: 9, blocks: 10, slam_dunks: 11 | |
| }, | |
| juan: { | |
| number: 3, shoe_size: 10, points: 7, rebounds: 8, assists: 9, steals: 10, blocks: 11, slam_dunks: 12 | |
| }, | |
| lon: { | |
| number: 4, shoe_size: 11, points: 12, rebounds: 13, assists: 14, steals: 15, blocks: 16, slam_dunks: 17 | |
| }, | |
| kahn!: { | |
| number: 5, shoe_size: 12, points: 100, rebounds: 14, assists: 15, steals: 160, blocks: 17, slam_dunks: 18 | |
| } | |
| } | |
| }, | |
| okay: { | |
| colors: ["green","yellow"], | |
| players:{ | |
| man: { | |
| number: 6, shoe_size: 13, points: 14, rebounds: 15, assists: 16, steals: 17, blocks: 18, slam_dunks: 19 | |
| }, | |
| dan: { | |
| number: 7, shoe_size: 14, points: 15, rebounds: 16, assists: 17, steals: 18, blocks: 19, slam_dunks: 20 | |
| }, | |
| fan: { | |
| number: 8, shoe_size: 15, points: 16, rebounds: 17, assists: 18, steals: 19, blocks: 20, slam_dunks: 21 | |
| }, | |
| lan: { | |
| number: 9, shoe_size: 16, points: 17, rebounds: 18, assists: 19, steals: 20, blocks: 21, slam_dunks: 22 | |
| }, | |
| han: { | |
| number: 10, shoe_size: 17, points: 18, rebounds: 19, assists: 20, steals: 21, blocks: 22, slam_dunks: 23 | |
| } | |
| } | |
| } | |
| } | |
| def point_return(team_hash, player_name) | |
| team_hash[:thebest][:players].include?(player_name) ? team_hash[:thebest][:players][player_name][:points] : team_hash[:okay][:players][player_name][:points] | |
| end | |
| def shoe_size(team_hash, player_name) | |
| team_hash[:thebest][:players].include?(player_name) ? team_hash[:thebest][:players][player_name][:shoe_size] : team_hash[:okay][:players][player_name][:shoe_size] | |
| end | |
| def team_color(team_hash, team_name) | |
| team_name == :thebest ? team_hash[:thebest][:colors].join(", ") : team_hash[:okay][:colors].join(", ") | |
| end | |
| def team_name(team_hash) | |
| team_hash.each { |k,v| puts "#{k}" } | |
| end | |
| def player_numbers(team_hash, team_name) | |
| team_hash[team_name][:players].each do |players_hash,player_hash| | |
| player_hash.each { |stat, value| puts "#{players_hash}: #{value}" if stat == :number } | |
| end | |
| end | |
| def return_stats(team_hash, player_name) | |
| team_hash[:thebest][:players].include?(player_name) ? team_hash[:thebest][:players][player_name] : team_hash[:okay][:players][player_name] | |
| end | |
| def big_shoe_rebound(team_hash) | |
| rebound_hash = {} | |
| team_hash[:thebest][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| rebound_hash[players_hash] = value if stat == :shoe_size | |
| end | |
| end | |
| team_hash[:okay][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| rebound_hash[players_hash] = value if stat == :shoe_size | |
| end | |
| end | |
| largest_foot = rebound_hash.max_by { |player, size| size }[0] | |
| team_hash[:thebest][:players].include?(largest_foot) ? team_hash[:thebest][:players][largest_foot][:rebounds] : team_hash[:okay][:players][largest_foot][:rebounds] | |
| end | |
| def most_points_players(team_hash) | |
| points_hash = {} | |
| team_hash[:thebest][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| points_hash[players_hash] = value if stat == :points | |
| end | |
| end | |
| team_hash[:okay][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| points_hash[players_hash] = value if stat == :points | |
| end | |
| end | |
| largest_foot = points_hash.max_by { |player, size| size }[0] | |
| end | |
| def most_points_teams(team_hash) | |
| best_points = [] | |
| okay_points = [] | |
| team_hash[:thebest][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| best_points << value if stat == :points | |
| end | |
| end | |
| team_hash[:okay][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| okay_points << value if stat == :points | |
| end | |
| end | |
| best_points.inject(&:+) > okay_points.inject(&:+) ? :thebest : :okay | |
| end | |
| def longest_name(team_hash) | |
| names = [] | |
| team_hash[:thebest][:players].each { |players_hash, player_hash| names << players_hash } | |
| team_hash[:okay][:players].each { |players_hash, player_hash| names << players_hash } | |
| names = names.sort_by {|x| x.length} | |
| while names[0].length < names[-1].length | |
| names.delete_at(0) | |
| end | |
| names | |
| end | |
| def longest_steals(team_hash) | |
| steals_hash = {} | |
| team_hash[:thebest][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| steals_hash[players_hash] = value if stat == :steals | |
| end | |
| end | |
| team_hash[:okay][:players].each do |players_hash, player_hash| | |
| player_hash.each do |stat, value| | |
| steals_hash[players_hash] = value if stat == :steals | |
| end | |
| end | |
| most_steals = steals_hash.max_by { |player, size| size }[0] | |
| longest_name(team_hash).join == most_steals.to_s | |
| end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment