Skip to content

Commit

Permalink
tasks 69, 71, 76, 99
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil157 committed Sep 11, 2015
1 parent 960253d commit db17096
Show file tree
Hide file tree
Showing 8 changed files with 1,061 additions and 9 deletions.
11 changes: 10 additions & 1 deletion helpers/math_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,13 @@ def spiral(n):
def is_prime(n):
if n % 2 == 0 and n > 2 or n < 2:
return False
return all(n % i for i in range(3, int(n ** 0.5) + 1, 2))
return all(n % i for i in range(3, int(n ** 0.5) + 1, 2))


def partitions(coins, target):
a = [0] * (target + 1)
a[0] = 1
for coin in coins:
for i in range(coin, target + 1):
a[i] += a[i - coin]
return a[target]
Loading

0 comments on commit db17096

Please sign in to comment.