diff options
Diffstat (limited to 'challenge-285/zapwai/python')
| -rw-r--r-- | challenge-285/zapwai/python/ch-1.py | 27 | ||||
| -rw-r--r-- | challenge-285/zapwai/python/ch-2.py | 13 |
2 files changed, 40 insertions, 0 deletions
diff --git a/challenge-285/zapwai/python/ch-1.py b/challenge-285/zapwai/python/ch-1.py new file mode 100644 index 0000000000..5722662b84 --- /dev/null +++ b/challenge-285/zapwai/python/ch-1.py @@ -0,0 +1,27 @@ +def proc(routes) : + print("Input: ") + for l in range(len(routes)): + print(" ",routes[l]) + inlist = [] + outlist = [] + for j in routes: + inlist.append(j[0]) + outlist.append(j[1]) + + ans = "a" + for needle in outlist : + found = 0 + for hay in inlist: + if needle == hay : + found = 1 + break + + if found == 0 : + ans = needle + + print("Output:", ans) + +routes = [["B","C"], ["D","B"], ["C","A"]] +proc(routes) +routes = [["A","Z"]] +proc(routes) 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.") |
