aboutsummaryrefslogtreecommitdiff
path: root/challenge-285/zapwai/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-285/zapwai/python/ch-2.py')
-rw-r--r--challenge-285/zapwai/python/ch-2.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-285/zapwai/python/ch-2.py b/challenge-285/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..c980cee622
--- /dev/null
+++ b/challenge-285/zapwai/python/ch-2.py
@@ -0,0 +1,13 @@
+def tally(p, n, d, q, h) :
+ return p + 5*n + 10*d + 25*q + 50*h
+amt = 100
+cnt = 0
+for h in range(1 + (int) (amt/50)) :
+ for q in range(1 + (int) (amt/25)) :
+ for d in range(1 + (int) (amt/10)) :
+ for n in range(1 + (int) (amt/5)) :
+ for p in range(1 + amt) :
+ if tally(p, n, d, q, h) == amt :
+ cnt += 1
+
+print("There are", cnt, "ways to make change for", amt, "cents.")