Skip to content

Instantly share code, notes, and snippets.

@miloshadzic
Created June 4, 2013 12:26
Show Gist options
  • Save miloshadzic/5705531 to your computer and use it in GitHub Desktop.
Save miloshadzic/5705531 to your computer and use it in GitHub Desktop.
def score dice
{1 => 100, 2 => 0, 3 => 0, 4 => 0, 5 => 50, 6 => 0}.map do |(n, score)|
occurences = dice.count n
(occurences / 3) * (n == 1 ? 1000 : n * 100) + (occurences % 3) * score
end.reduce :+
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment