Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 22 lines (17 sloc) 0.451 kb
acb757da »
2009-10-22 Solved 31, but I think I can clean it up some
1 coins = [200, 100, 50, 20, 10, 5, 2, 1]
d290b2d4 »
2009-10-11 Poker! What happened to my saturday night?
2 goal = 200
3
acb757da »
2009-10-22 Solved 31, but I think I can clean it up some
4 def chase(coins, goal):
5 total = 0
6 x = goal / coins[0]
7
8 new_coins = coins[1:]
9
10 if len(new_coins):
11 for i in range(x, -1, -1):
12 new_goal = goal - (i * coins[0])
13 if new_goal == 0:
14 total += 1
15 else:
16 total += chase(new_coins, new_goal)
17 else:
18 total = 1
19 return total
20
21 print chase(coins, goal)
Something went wrong with that request. Please try again.