Permalink
Browse files

greed

  • Loading branch information...
1 parent fe7d0f2 commit 1ba49c3a0eb5a8a7a986183a0f259ca01645a893 Danish Khan committed Apr 5, 2012
Showing with 16 additions and 3 deletions.
  1. +16 −3 koans/about_scoring_project.rb
@@ -31,9 +31,22 @@
def score(dice)
# You need to write this method
- if dice == []
- return 0
- end
+ # make the hash default to 0 so that += will work correctly
+ hash = Hash.new(0)
+
+ dice.each do |v|
+ hash[v] += 1
+ end
+
+ hash.each do |k, v|
+ if ( k == 1 )
+ if ( v == 1 )
+ return 100
+ elsif ( v == 2 )
+ return 200
+ elsif ( v == 3 )
+ return
+ end
end
class AboutScoringProject < EdgeCase::Koan

0 comments on commit 1ba49c3

Please sign in to comment.