A snake is crawling down on one side of a pyramid, while eating eggs on each step. There is one egg on the top step of the pyramid, two eggs on the next step, three on the next and so on. The snake can only eat one egg on each step, and it can only move one egg to the left or one to the right at each step. Given a 2-D array of positive weights for each egg, return the maximum weight of eggs the snake can eat. As an example:
[ [9*], [9*, 1], [9*, 2, 1], [1, 6*, 1, 9] ]
The maximum weight is achieved by eating the starred eggs:
33 = 9 + 9 + 9 + 6.
pyramid([ [ 9 ], [ 9, 1 ], [ 9, 2, 1 ], [ 1, 6, 1, 9 ] ]);