Skip to content

Commit

Permalink
A couple minor fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
w-hat committed Apr 6, 2017
1 parent 77b2bb7 commit 714cf54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ch-07-object-oriented-design/01-deck-of-cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def __init__(self, cards):

def shuffle(self):
for i in xrange(len(self.cards)):
o = random.randint(len(self.cards))
o = random.randint(i)
self.cards[i], self.cards[o] = self.cards[o], self.cards[i]

def draw_card(self):
Expand Down
11 changes: 5 additions & 6 deletions ch-08-recursion-and-dynamic-programming/01-triple-step.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# Give the number of ways to climb n steps 1, 2, or 3 steps at a time.

def triple_step(n):
counts = [1, 1, 2, 4]
if n < 4:
counts = [1, 1, 2]
if n < 3:
return counts[n]
i = 3
i = 2
while i < n:
i += 1
counts[i % 4] = 0
counts[i % 4] = sum(counts)
return counts[i % 4]
counts[i % 3] = sum(counts)
return counts[i % 3]

import unittest

Expand Down

0 comments on commit 714cf54

Please sign in to comment.