diff options
| author | David Ferrone <zapwai@gmail.com> | 2024-09-02 12:36:30 -0400 |
|---|---|---|
| committer | David Ferrone <zapwai@gmail.com> | 2024-09-02 12:36:30 -0400 |
| commit | a144bedd098858190c4b504282b667e7cbc0a37c (patch) | |
| tree | 5cc3ecadd2d9cd04f3ce2724ddeea68c935fcdce /challenge-285/zapwai/python | |
| parent | a92117f754a875572d11900c871014386b7ade27 (diff) | |
| download | perlweeklychallenge-club-a144bedd098858190c4b504282b667e7cbc0a37c.tar.gz perlweeklychallenge-club-a144bedd098858190c4b504282b667e7cbc0a37c.tar.bz2 perlweeklychallenge-club-a144bedd098858190c4b504282b667e7cbc0a37c.zip | |
Week 285
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.") |
