aboutsummaryrefslogtreecommitdiff
path: root/challenge-147/abigail/python/ch-1.py
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-01-18 10:37:54 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-01-18 10:37:54 +0000
commit5bd157274f9d0377833a954cf48d6b4866615aae (patch)
tree804cbbdb2fd3d9de5864c736e5088677f94bf898 /challenge-147/abigail/python/ch-1.py
parent990d5177887cda20c8a4804b91afe5e9bcaaf201 (diff)
parent4c0094aa3f456810b1795784caa1fe06fbdacb5c (diff)
downloadperlweeklychallenge-club-5bd157274f9d0377833a954cf48d6b4866615aae.tar.gz
perlweeklychallenge-club-5bd157274f9d0377833a954cf48d6b4866615aae.tar.bz2
perlweeklychallenge-club-5bd157274f9d0377833a954cf48d6b4866615aae.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-147/abigail/python/ch-1.py')
-rw-r--r--challenge-147/abigail/python/ch-1.py37
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")