Skip to content

Commit

Permalink
like coin change problem76
Browse files Browse the repository at this point in the history
  • Loading branch information
wengjn committed May 4, 2012
1 parent a6fd033 commit e19e582
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions solutions/76.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#! /usr/bin/python
# filename: 76.py

'''
how many different ways can one hundred be written as a sum of positive
integers, at least 2
this problem is like coin changing problem31
dynamic programming
need to look it more carefully from this on
'''


def main():

target = 100
ns = range(1, 100)
ways = [1] + [0]*target

for n in ns:
for i in range(n, target+1):
ways[i] += ways[i-n]

print ways[target]


if __name__ == '__main__':
main()

0 comments on commit e19e582

Please sign in to comment.