From 41ef277f401bf04b96b68aaf27b053454f8a9769 Mon Sep 17 00:00:00 2001 From: capitalist Date: Tue, 10 Feb 2009 14:41:51 -0700 Subject: [PATCH] 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 --- koans/about_scoring_project.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/koans/about_scoring_project.rb b/koans/about_scoring_project.rb index b5ac7fd..fcd4206 100644 --- a/koans/about_scoring_project.rb +++ b/koans/about_scoring_project.rb @@ -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