aboutsummaryrefslogtreecommitdiff
path: root/challenge-139/abigail/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-139/abigail/python')
-rw-r--r--challenge-139/abigail/python/ch-1.py19
-rw-r--r--challenge-139/abigail/python/ch-2.py32
2 files changed, 51 insertions, 0 deletions
diff --git a/challenge-139/abigail/python/ch-1.py b/challenge-139/abigail/python/ch-1.py
new file mode 100644
index 0000000000..f2a73b2d4a
--- /dev/null
+++ b/challenge-139/abigail/python/ch-1.py
@@ -0,0 +1,19 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+
+for line in fileinput . input ():
+ list = line . split (" ")
+ sorted = 1
+ for i in range (1, len (list)):
+ if list [i - 1] > list [i]:
+ sorted = 0
+ print (sorted)
diff --git a/challenge-139/abigail/python/ch-2.py b/challenge-139/abigail/python/ch-2.py
new file mode 100644
index 0000000000..509bfa8ee5
--- /dev/null
+++ b/challenge-139/abigail/python/ch-2.py
@@ -0,0 +1,32 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py
+#
+
+BASE = 10
+COUNT = 5
+
+def is_long (number):
+ seen = [0] * number
+ rest = 0
+ for _ in range (1, number):
+ rest = (rest * BASE + BASE - 1) % number
+ if seen [rest] == 1:
+ return False
+ seen [rest] = 1
+ return True
+
+
+number = 1
+while COUNT > 0:
+ number = number + 1
+ if BASE % number == 0:
+ continue
+ if is_long (number):
+ print (number)
+ COUNT = COUNT - 1