Skip to content

Instantly share code, notes, and snippets.

@pathouse
Last active December 17, 2015 16:39
Show Gist options
  • Save pathouse/5640776 to your computer and use it in GitHub Desktop.
Save pathouse/5640776 to your computer and use it in GitHub Desktop.
Working through the Greed scoring problem in Ruby Koans, the first two lines of my solution made me smile. Thanks Ruby. For context, 'dice' is an array of 5 numbers representing 5 die rolls.
def score(dice)
dice_hash = {"1" => 0, "2" => 0, "3" => 0, "4" => 0, "5" => 0, "6" => 0}
count = dice.each {|x| dice_hash[x.to_s] += 1}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment