# Golden Pyramid

Elementary+
English FR HU JA RU UK ZH-HANS

Our Robo-Trio need to train for future journeys and treasure hunts. Stephan has built a special flat model of a pyramid. Now the robots can train for speed gold running. They start at the top of the pyramid and must collect gold in each room, choose to take the left or right path and continue down to the next level. To optimize their gold runs, Stephan need to know the maximum amount of gold that can be collected in one run.

Consider a list of lists in which the first list has one integer and each consecutive list has one more integer then the last. Such a list of lists would look like a pyramid. You should write a program that will help Stephan find the highest possible sum on the most profitable route down the pyramid. All routes down the pyramid involve stepping down and to the left or down and to the right.

Tips: Think of each step down to the left as moving to the same index location or to the right as one index location higher. Be very careful if you plan to use recursion here.

Input: A pyramid as a list of lists of integers.

Output: The maximum possible sum as an integer.

Examples:

```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
)
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
)
assert count_gold([[9], [2, 2], [3, 3, 3], [4, 4, 4, 4]]) == 18
assert (
count_gold(
[[2], [7, 9], [0, 8, 6], [4, 7, 6, 8], [0, 5, 5, 4, 1], [9, 1, 0, 1, 6, 9]]
)
== 35
)
```

How it is used: this is a classical problem which shows you how to use dynamic programming. This concept is a core component of many optimizations tasks.

Preconditions:

• 0 < len(pyramid) ≤ 20;
• all(all(0 < x < 10 for x in row) for row in pyramid).

45
Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
•  to Run Code: to Check Solution: to Stop:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

`pip3 install checkio_client`

`checkio --domain=py config --key=`

Sync solutions into your local folder

`checkio sync`

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

`checkio serv -d`

Alternatevly, you can install Chrome extension or FF addon

`checkio install-plugin`
`checkio install-plugin --ff`
`checkio install-plugin --chromium`

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.