Fixed typo and faulty expectation.

There are three twos = 200 and one five = 50 => so this should be 250

Also, here's my score method - I feel like I over complicated this:
# def score(dice)
#   #count em up
#   results = dice.inject(Hash.new) {|h, die| h[die] = h[die] ? h[die] + 1 : 1; h }
#
#   #convert to scores
#   score = results.keys.inject(0) do |s,k|
#     s += \
#     case k
#     when 1
#       results[k] >= 3 ? 1000 + (results[k]-3)*100  : results[k] * 100
#     when 2..4,6
#       results[k] >= 3 ? 100*k : 0
#     when 5
#       results[k] >= 3 ? 500 + (results[k]-3)*50  : results[k] * 50
#     else
#       0
#     end
#   end
# end
This commit is contained in:
capitalist
2009-02-10 14:41:51 -07:00
committed by Marc Peabody
parent d9e77d26f2
commit 41ef277f40

View File

@@ -25,7 +25,7 @@ require 'edgecase'
# score([3,4,5,3,3]) => 350 points
# score([1,5,1,2,4]) => 250 points
#
# More scoing examples are given in the tests below:
# More scoring examples are given in the tests below:
#
# Your goal is to write the score method.
@@ -67,7 +67,7 @@ class AboutScoringAssignment < EdgeCase::Koan
end
def test_score_of_mixed_is_sum
assert_equal 50, score([2,5,2,2,3])
assert_equal 250, score([2,5,2,2,3])
assert_equal 550, score([5,5,5,5])
end