aboutsummaryrefslogtreecommitdiff
path: root/challenge-151/abigail/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-151/abigail/python/ch-2.py')
-rw-r--r--challenge-151/abigail/python/ch-2.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/challenge-151/abigail/python/ch-2.py b/challenge-151/abigail/python/ch-2.py
new file mode 100644
index 0000000000..52522eff0b
--- /dev/null
+++ b/challenge-151/abigail/python/ch-2.py
@@ -0,0 +1,19 @@
+#!/usr/local/bin/python3
+
+#
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-151
+#
+
+#
+# Run as: python ch-2.py < input-file
+#
+
+import fileinput
+
+for line in fileinput . input ():
+ h = list (map (lambda x: int (x), line . strip () . split ()))
+ h . append (0)
+ h . append (0)
+ for i in range (len (h) - 3, 1, -1):
+ h [i] = max (h [i] + h [i + 2], h [i + 1])
+ print (h [0] + h [2])