I would like to give some feedback about ...
From: https://checkio.org/mission/golden-pyramid/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/50.0.2661.102 Chrome/50.0.2661.102 Safari/537.36
For this puzzle, I see the response for 8 basic tests and 11 extra tests all saying that I passed, yet, it is telling me that I failed. I don't understand why.
Here is the contents of pyramid.py if that helps.
def count_gold(pyramid):
paths = {"0-0":pyramid[0][0]}
for y in range(len(pyramid)):
line = pyramid[y]
for x in range(len(line)):
if (y +1 != len(pyramid)):
keys = [x for x in paths.keys()]
for key in keys:
if key.find("%s-%s"%(x,y)) != -1:
nY = y + 1
for dx in range(2):
nX = x + dx
newKey = key + ",%s-%s"%(nX, nY)
paths[newKey] = paths[key] + pyramid[nY][nX]
values = []
for key in paths.keys():
values += [paths[key]]
rtn = max(values)
return rtn
"""
Return max possible sum in a path from top to bottom
"""
#replace this for solution
return 0
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert count_gold((
(1,),
(2, 3)
)) == 4, "simple example"
assert 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)
)) == 23, "First example"
assert count_gold((
(1,),
(2, 1),
(1, 2, 1),
(1, 2, 1, 1),
(1, 2, 1, 1, 1),
(1, 2, 1, 1, 1, 1),
(1, 2, 1, 1, 1, 1, 9)
)) == 15, "Second example"
assert count_gold((
(9,),
(2, 2),
(3, 3, 3),
(4, 4, 4, 4)
)) == 18, "Third example"
Created at: 2016/06/04 04:45; Updated at: 2016/06/06 19:15