aboutsummaryrefslogtreecommitdiff
path: root/challenge-151/abigail/python/ch-2.py
blob: 52522eff0b5702f223db9dc5c89052772e1ae9bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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])