aboutsummaryrefslogtreecommitdiff
path: root/challenge-111/abigail/python/ch-1.py
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-05-04 17:49:26 +0200
committerAbigail <abigail@abigail.be>2021-05-04 17:59:55 +0200
commitc740d8f54a4355f0d4b58715962541ea9c473597 (patch)
treeca4bef4d1a36cf1d6696779c3a7e3ded45d3f06e /challenge-111/abigail/python/ch-1.py
parent120ddabba9a2e7583c5eeb66d4cc4a463f8cedc2 (diff)
downloadperlweeklychallenge-club-c740d8f54a4355f0d4b58715962541ea9c473597.tar.gz
perlweeklychallenge-club-c740d8f54a4355f0d4b58715962541ea9c473597.tar.bz2
perlweeklychallenge-club-c740d8f54a4355f0d4b58715962541ea9c473597.zip
Python solution for week 111, part 1
Diffstat (limited to 'challenge-111/abigail/python/ch-1.py')
-rw-r--r--challenge-111/abigail/python/ch-1.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-111/abigail/python/ch-1.py b/challenge-111/abigail/python/ch-1.py
new file mode 100644
index 0000000000..ba91c8009f
--- /dev/null
+++ b/challenge-111/abigail/python/ch-1.py
@@ -0,0 +1,31 @@
+#!/opt/local/bin/python
+
+#
+# See ../README.md
+#
+
+#
+# Run as: python ch-1.py < input-file
+#
+
+MATRIX_SIZE = 5
+
+import fileinput
+import re
+
+#
+# Read in the matrix
+#
+matrix = {}
+for i in range (MATRIX_SIZE):
+ for n in re . findall (r'-?[0-9]+', input ()):
+ matrix [n] = 1
+
+#
+# For the rest of the input, check whether it's in the matrix
+#
+for line in fileinput . input ():
+ if line . strip () in matrix:
+ print ("1")
+ else:
+ print ("0")