Skip to content

Afaren/dice-scoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Dice Scoring

This example is inspired by ruby_koans.

Greed is a dice game where you roll up to a mount of dice to accumulate points. The following “score” function will be used calculate the score of a single roll of the dice.

A greed roll is scored as follows:

  • A set of three ones is 1000 points
  • A set of three numbers (other than ones) is worth 100 times the number. (e.g. three fives is 500 points).
  • A one (that is not part of a set of three) is worth 100 points.
  • A five (that is not part of a set of three) is worth 50 points.
  • Everything else is worth 0 points.

Examples:

  • gscore([1, 1, 1, 5, 1]) => 1150 points
  • score([2, 3, 4, 6, 2]) => 0 points
  • score([3, 4, 5, 3, 3]) => 350 points
  • score([1, 5, 1, 2, 4]) => 250 points
  • score([1, 1, 1, 1, 1, 1, 1]) => 2100 points
  • score([5, 5, 5, 5, 5, 5]) => 1000 points
  • score([3, 3, 3, 3, 3, 3]) => 600 points
  • score([3, 3, 3, 3, 3, 3, 3, 3, 3]) => 900 points
  • score([3, 3, 3, 2, 2, 2, 1, 1, 1]) => 1500 points

More scoring examples are given in the tests below:

Your goal is to write the score method.

Releases

No releases published

Packages

No packages published