From d3f5000dad878c20e1d6bd050ae30ad0999bf4d6 Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Thu, 17 Mar 2016 11:55:59 +0100 Subject: [PATCH] Pyramid kata --- pyramid.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 pyramid.py diff --git a/pyramid.py b/pyramid.py new file mode 100644 index 0000000..109f5a3 --- /dev/null +++ b/pyramid.py @@ -0,0 +1,10 @@ +def longest_slide_down(pyramid): + paths = [0] + for step in pyramid: + print(paths) + paths = [paths[0]+step[0]] + list([max(da+a,db+b) for da,a,db,b in zip(step[:-1],paths[:-1],step[1:],paths[1:])]) + [paths[-1]+step[-1]] + print(paths) + + return max(paths) + +print(longest_slide_down([[3],[7,4],[2,4,6],[8,5,9,3]]))