Light Mode
Dark Mode
Feedback from user AngelRaposo
The first test seems to be failing but the same code in the coding area seems to be working (try it option).

Not sure if I'm doing something wrong but seems some difference between the input type in the test is happening somewhere...

Example code currently executed:

def count_gold(pyramid):
    """
    Return max possible sum in a path from top to bottom
    """
    result = list([pyramid[0]])
    #print result
    for level in xrange(1, len(pyramid)):
        # One loop per level 
        line = list(pyramid[level])
        #print "line", line
        for index in range(len(line)):
            if index-1 < 0:
                line[index] += result[index]
            else:
                if index == len(result):
                    line[index] += result[index-1]
                else:
                    line[index] += max(result[index-1], result[index])
        result = line
        #print "result", result
    return max(result)

print count_gold(((1),(2,3),(3,3,1),(3,1,5,4),(3,1,3,1,3),(2,2,2,2,2,2),(5,6,4,5,6,4,3)))

URL from: http://www.checkio.org/mission/golden-pyramid/solve/
HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36
Attachment
  • feedback
Created: May 14, 2014, 6:03 a.m.
Updated: May 14, 2014, 6:03 a.m.
0
16
User avatar
AngelRaposo