aboutsummaryrefslogtreecommitdiff
path: root/challenge-140/abigail/python
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-140/abigail/python')
-rw-r--r--challenge-140/abigail/python/ch-1.py15
-rw-r--r--challenge-140/abigail/python/ch-2.py25
2 files changed, 40 insertions, 0 deletions
diff --git a/challenge-140/abigail/python/ch-1.py b/challenge-140/abigail/python/ch-1.py
new file mode 100644
index 0000000000..7002b13c03
--- /dev/null
+++ b/challenge-140/abigail/python/ch-1.py
@@ -0,0 +1,15 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+import fileinput
+
+for line in fileinput . input ():
+ a, b = line . strip () . split (" ")
+ print (bin (int (a, 2) + int (b, 2)) [2:])
diff --git a/challenge-140/abigail/python/ch-2.py b/challenge-140/abigail/python/ch-2.py
new file mode 100644
index 0000000000..a7bdccbb49
--- /dev/null
+++ b/challenge-140/abigail/python/ch-2.py
@@ -0,0 +1,25 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+import math
+
+for line in fileinput . input ():
+ i, j, k = map (lambda x: int (x), line . strip () . split (" "))
+ n = 0
+ while k > 0:
+ n = n + 1
+ s = math . floor (math . sqrt (n))
+ for d in range (1, s + 1):
+ if n % d == 0:
+ if d <= i and n / d <= j: k = k - 1
+ if d <= j and n / d <= i: k = k - 1
+ if n == d * d: k = k + 1
+ print (n)