[Community Puzzle] Staircases

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Hi,
Running the staircase puzzle on my laptop takes 8seconds
The answer is correct but apparently this is not suffficently optimised so the test fails…

I’m using recursivity,
And saving past results with staircaseHeight, nbStepsLeft and nbSolutions (for this combination)
then checking if I can reuse those

Is there something else out there that I’m missing to optimise the speed?

Your approach of using recursion with memoisation sounds solid in principle. When you mentioned 8 seconds, did you mean the time for running all the five test cases, or just Test 4 (n = 500)? Either way, you may try to:

  • Add debug outputs to verify that your memoised results are being reused as expected

  • Test whether an alternative memoisation data structure is more efficient

It takes 8seconds to run the test4 with 500
Thx thats good advice, will play with other data structure