diff options
Diffstat (limited to 'challenge-151/abigail/python')
| -rw-r--r-- | challenge-151/abigail/python/ch-2.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/challenge-151/abigail/python/ch-2.py b/challenge-151/abigail/python/ch-2.py index a20a18329b..52522eff0b 100644 --- a/challenge-151/abigail/python/ch-2.py +++ b/challenge-151/abigail/python/ch-2.py @@ -11,8 +11,9 @@ import fileinput for line in fileinput . input (): - houses = list (map (lambda x: int (x), line . strip () . split ())) - best = [0] * (len (houses) + 2) - for i in range (len (houses) - 1, 1, -1): - best [i] = max (houses [i] + best [i + 2], best [i + 1]) - print (houses [0] + best [2]) + 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]) |
