diff options
| author | Abigail <abigail@abigail.freedom.nl> | 2022-01-31 15:50:18 +0100 |
|---|---|---|
| committer | Abigail <abigail@abigail.freedom.nl> | 2022-01-31 19:47:29 +0100 |
| commit | 8487fe3f219c99dc720f99e2d53197c211deaf5b (patch) | |
| tree | 97a4990ae8dfa3601c30efc7863baa5e5b4d4e37 /challenge-150/abigail/python | |
| parent | d52aa060e5c7663353b4d1a0186b608ef520dc9e (diff) | |
| download | perlweeklychallenge-club-8487fe3f219c99dc720f99e2d53197c211deaf5b.tar.gz perlweeklychallenge-club-8487fe3f219c99dc720f99e2d53197c211deaf5b.tar.bz2 perlweeklychallenge-club-8487fe3f219c99dc720f99e2d53197c211deaf5b.zip | |
Week 150: Solutions
Diffstat (limited to 'challenge-150/abigail/python')
| -rw-r--r-- | challenge-150/abigail/python/ch-1.py | 17 | ||||
| -rw-r--r-- | challenge-150/abigail/python/ch-2.py | 22 |
2 files changed, 39 insertions, 0 deletions
diff --git a/challenge-150/abigail/python/ch-1.py b/challenge-150/abigail/python/ch-1.py new file mode 100644 index 0000000000..7d56fa686d --- /dev/null +++ b/challenge-150/abigail/python/ch-1.py @@ -0,0 +1,17 @@ +#!/usr/local/bin/python3 + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-150 +# + +# +# Run as: python ch-1.py < input-file +# + +import fileinput + +for line in fileinput . input (): + fib_prev, fib_last = line . strip () . split (" ") + while len (fib_last) < 51: + fib_prev, fib_last = fib_last, fib_prev + fib_last + print (fib_last [50:51]) diff --git a/challenge-150/abigail/python/ch-2.py b/challenge-150/abigail/python/ch-2.py new file mode 100644 index 0000000000..c1fd1e5447 --- /dev/null +++ b/challenge-150/abigail/python/ch-2.py @@ -0,0 +1,22 @@ +#!/usr/local/bin/python3 + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-150 +# + +# +# Run as: python ch-2.py +# + +import sys + +primes = [2, 3, 5, 7, 11, 13, 17, 19] + +for n in range (1, 501): + has_square = False + for p in primes: + if n % (p * p) == 0: + has_square = True + if not has_square: + sys . stdout . write (str (n) + " ") +sys . stdout . write ("\n") |
