aboutsummaryrefslogtreecommitdiff
path: root/challenge-118/abigail/python/ch-1.py
diff options
context:
space:
mode:
authorE7-87-83 <fungcheokyin@gmail.com>2021-07-04 22:18:36 +0800
committerE7-87-83 <fungcheokyin@gmail.com>2021-07-04 22:18:36 +0800
commit28eabc69c70046cc047e98e2b2987d71b4aae9fa (patch)
treef2fe2351445f68451ec14f21072719bc9db488b0 /challenge-118/abigail/python/ch-1.py
parentcdfef3f9404041b4c7936a26532757e63fd4fcef (diff)
parent5f7b76d5b841606c17f177a90397196ebf434c05 (diff)
downloadperlweeklychallenge-club-28eabc69c70046cc047e98e2b2987d71b4aae9fa.tar.gz
perlweeklychallenge-club-28eabc69c70046cc047e98e2b2987d71b4aae9fa.tar.bz2
perlweeklychallenge-club-28eabc69c70046cc047e98e2b2987d71b4aae9fa.zip
week 119
Diffstat (limited to 'challenge-118/abigail/python/ch-1.py')
-rw-r--r--challenge-118/abigail/python/ch-1.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-118/abigail/python/ch-1.py b/challenge-118/abigail/python/ch-1.py
new file mode 100644
index 0000000000..df0451a44e
--- /dev/null
+++ b/challenge-118/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 ():
+ bin = '{:b}' . format (int (line)) # Turn to binary representation
+ if bin == bin [::-1]: # bin [::-1] reverse the string
+ print (1)
+ else:
+ print (0)
+