diff options
| author | Abigail <abigail@abigail.freedom.nl> | 2021-12-27 18:20:34 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.freedom.nl> | 2021-12-29 20:19:41 +0100 |
| commit | a7cfe19e7988033b8b37d4effedcf01ee203ff0e (patch) | |
| tree | ab78dd124aef81b9f58ec35ca24e9b768e1d3512 /challenge-145/abigail/python | |
| parent | 767f501835ea07823607293b532b6a0520fafc3b (diff) | |
| download | perlweeklychallenge-club-a7cfe19e7988033b8b37d4effedcf01ee203ff0e.tar.gz perlweeklychallenge-club-a7cfe19e7988033b8b37d4effedcf01ee203ff0e.tar.bz2 perlweeklychallenge-club-a7cfe19e7988033b8b37d4effedcf01ee203ff0e.zip | |
Week 145
Diffstat (limited to 'challenge-145/abigail/python')
| -rw-r--r-- | challenge-145/abigail/python/ch-1.py | 18 | ||||
| -rw-r--r-- | challenge-145/abigail/python/ch-2.py | 23 |
2 files changed, 41 insertions, 0 deletions
diff --git a/challenge-145/abigail/python/ch-1.py b/challenge-145/abigail/python/ch-1.py new file mode 100644 index 0000000000..43913ceb0e --- /dev/null +++ b/challenge-145/abigail/python/ch-1.py @@ -0,0 +1,18 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-1.py < input-file +# + +a = [int (x) for x in input () . split (" ")] +b = [int (x) for x in input () . split (" ")] + +sum = 0 +for i in range (len (a)): + sum = sum + a [i] * b [i] + +print (sum) diff --git a/challenge-145/abigail/python/ch-2.py b/challenge-145/abigail/python/ch-2.py new file mode 100644 index 0000000000..e3bd9f7986 --- /dev/null +++ b/challenge-145/abigail/python/ch-2.py @@ -0,0 +1,23 @@ +#!/opt/local/bin/python + +# +# See ../README.md +# + +# +# Run as: python ch-2.py < input-file +# + +import fileinput + +for line in fileinput . input (): + palindromes = {} + out = "" + for i in range (0, len (line)): + for j in range (i + 1, len (line)): + string = line [i : j] + if string == string [::-1]: + if not (string in palindromes): + palindromes [string] = 1 + out = out + string + " " + print (out) |
