Skip to content

Web company's Triangle Challenge you must transverse Triangle to find the sum: About dozen lines of Python

License

Notifications You must be signed in to change notification settings

yelled1/triangleSumSolution

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

triangleSumSolution

A Web company's Triangle Challenge you must transverse Triangle to find the sum: About dozen lines of Python This is pre interview Q by a web company that screens the candidates by this puzzle. I seen a few java and other answers that did THE algorithm, but mine is extremely simple About Dozen lines in Python. This may not be the most sophisticated answer but I am pretty sure this is likely the shortest & most understandable KISS principle at work Here's the Q #By starting at the top of the triangle and moving to adjacent numbers on the row below, the maximum total from top to bottom is 27.

    5
  9  6
4   6  8

0 7 1 5

#I.e. 5 + 9 + 6 + 7 = 27 One just have to travel down keeping track of indexes & next Few lines 3~4 for sanity check but not much beyond that

About

Web company's Triangle Challenge you must transverse Triangle to find the sum: About dozen lines of Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages