diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2021-11-26 13:16:22 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-26 13:16:22 +0000 |
| commit | df966962c65252efa22bc8b686013c9c1b0f8680 (patch) | |
| tree | 2cf0b1edf0048ce1058d557b9d6a424e0f6fca2a /challenge-140/abigail/python | |
| parent | c58aa139f267a08aee64b3129f854b6e637022b3 (diff) | |
| parent | 5e0ab324c5a454538d112d0930d0fa15d6c8c4b7 (diff) | |
| download | perlweeklychallenge-club-df966962c65252efa22bc8b686013c9c1b0f8680.tar.gz perlweeklychallenge-club-df966962c65252efa22bc8b686013c9c1b0f8680.tar.bz2 perlweeklychallenge-club-df966962c65252efa22bc8b686013c9c1b0f8680.zip | |
Merge pull request #5283 from Abigail/abigail/week-140
Abigail/week 140
Diffstat (limited to 'challenge-140/abigail/python')
| -rw-r--r-- | challenge-140/abigail/python/ch-1.py | 15 | ||||
| -rw-r--r-- | challenge-140/abigail/python/ch-2.py | 25 |
2 files changed, 40 insertions, 0 deletions
diff --git a/challenge-140/abigail/python/ch-1.py b/challenge-140/abigail/python/ch-1.py new file mode 100644 index 0000000000..7002b13c03 --- /dev/null +++ b/challenge-140/abigail/python/ch-1.py @@ -0,0 +1,15 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-1.py < input-file +# + +import fileinput + +for line in fileinput . input (): + a, b = line . strip () . split (" ") + print (bin (int (a, 2) + int (b, 2)) [2:]) diff --git a/challenge-140/abigail/python/ch-2.py b/challenge-140/abigail/python/ch-2.py new file mode 100644 index 0000000000..a7bdccbb49 --- /dev/null +++ b/challenge-140/abigail/python/ch-2.py @@ -0,0 +1,25 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-2.py < input-file +# + +import fileinput +import math + +for line in fileinput . input (): + i, j, k = map (lambda x: int (x), line . strip () . split (" ")) + n = 0 + while k > 0: + n = n + 1 + s = math . floor (math . sqrt (n)) + for d in range (1, s + 1): + if n % d == 0: + if d <= i and n / d <= j: k = k - 1 + if d <= j and n / d <= i: k = k - 1 + if n == d * d: k = k + 1 + print (n) |
