Description in the code:
You must collect the required amount of gold.
# The gate keeper will tell you how much you need.
# Always move in the direction of the exit.
# For each row you can take only one coin.
# Choose only one from the nearest coins in the next row.
The gate keeper will tell you how much gold you need to collect.
Move in the direction of the exit.
After each coin choose one of the two (or one for edges) nearest coins in the next row.
Don’t stop and move exactly to the next coin. One wrong step and deadly beams will burn you.
And this is how I interpreted it:
- Look for a way to read the gatekeepers number
- Use this number as the magic key to search for during the execution of the algorithm
- Create an algorithm that checks each node in the next row (up to 2 checks)
- Stop when you reach the gatekeepers number and exit the algorithm
- Build a “path” through the coins that can be later traversed
- Walk to the door to exit the level
After preliminary assessment of the problem it was apparent that if we check 2 options per row per node it becomes 2^n. So for 10 rows it was 2^10 or 512. And since we had 10 columns or starting nodes, it was a maximum for 5,120 checks to solve the problem. Though since we were restricted to a small space and not a trapezoid the checks would range from the edge case of ~256 to the center of ~512. So somewhere around 3,900 tests. I resolved that recursion in this case would be fine as there were limited tests < 10k.
What I found frustrating is that I kept thinking that the warlock had a secret property that I could read like “.vale” or something to get this number. Since other levels in the game allowed you to do this it had created that association for me.
Perhaps what might have helped me is a statement like the following.
“Are you as smart as the gatekeeper of time?”
“The gatekeeper of time knows all and has instantly chosen the path with the greatest amount of gold”
“Can you find this path before time runs out?”
“The gatekeeper says how much gold is in the path, but you will have to find the right path on your own”
“Look for the path with the greatest amount of gold”