diff options
Diffstat (limited to 'challenge-147/abigail/python/ch-1.py')
| -rw-r--r-- | challenge-147/abigail/python/ch-1.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/challenge-147/abigail/python/ch-1.py b/challenge-147/abigail/python/ch-1.py new file mode 100644 index 0000000000..cd317b880b --- /dev/null +++ b/challenge-147/abigail/python/ch-1.py @@ -0,0 +1,37 @@ +#!/usr/local/bin/python3 + +# +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-147 +# + +# +# Run as: python ch-1.py +# + +import sys +from sympy import isprime + +todo = [2, 3, 5, 7] +[sys . stdout . write (str (x) + " ") for x in todo] +count = 20 - len (todo) + +pow = 10 +while count > 0: + new_todo = [] + for d in range (1, 10): + for p in todo: + candidate = d * pow + p + if isprime (candidate): + sys . stdout . write (str (candidate) + " ") + count = count - 1 + new_todo . append (candidate) + if count <= 0: + break + if count <= 0: + break + if count <= 0: + break + todo = new_todo + pow = pow * 10 + +sys . stdout . write ("\n") |
