Commits

Christoph Schindler  committed e3a5c14

pair 3

  • Participants
  • Parent commits 6fbef24
  • Branches dojo-2012-10-21

Comments (0)

Files changed (2)

File BowlingWithAVengeance/bowling.py

     
 def get_score(frames):
     score = 0
-    
+    score = sum(frame_score(frame) for frame in frames[:10])
     for index, frame in enumerate(frames):
-        score += frame_score(frame)
-        if index < len(frames) - 1:
+        if index < len(frames) - 1 and index < 10:
             # if this is not the last frame, we might want to
             # look at future frames for additional scores
             next_frame = frames[index+1]
                     next_next_frame = frames[index+2]
                     score += next_next_frame[0]
             elif is_spare(frame):
-                score += 2
+                score += next_frame[0]
     return score

File BowlingWithAVengeance/test.py

     assert_equal(bowling.get_score(((10,), (10,), (10,), (2,4))), 30+22+16+6)
     
 def test_spare():
-    assert_equal(bowling.get_score(((1, 9), (2, 4))), 18)
+    assert_equal(bowling.get_score(((1, 9), (2, 4))), 18)
+        
+def test_spare_2():
+    assert_equal(bowling.get_score(((1, 9), (3, 4))), 20)
+    
+def test_perfect_game():
+    assert_equal(bowling.get_score([(10,)] * 12), 300)