Coding: final assignment

Help needed. I have been struggling with this assignment and was hoping that you could help me. The assignment is as follow:

The comments from this post are quite helpful for solving this puzzle:

In particular, @Grasshopper_Heather explains the logic behind the solution required:

Here is a working solution from @Carpe_diem:

Final Ascent solution

The Final Ascent explainer - #9 by Carpe_diem