Very slowly still going through this.
Solving problem #4 was kind of cathartic.
Found a good recurrence relationship (where solving for q(n) requires solving for smaller values. Was running into an issue where it was running immensely slow. Smaller values than 70 were running almost instantly. Larger values didn't seem to be finishing. I ran it for like 10 minutes and it never finished.
Added a hashmap to store older results, but it wasn't having the expected performance improvement.
Went to bed at midnight. 5 minutes later, had a feeling that I was checking inputs against the outputs, instead of checking inputs against previous inputs.
Fixed that. It ran nearly instantly even for very large values, and immediately showed that it solved all the test cases. Whereas before google would hang for a good minute before telling me several cases failed.
Actually gave me similar feelings to beating a Dark Souls boss.
Solving problem #4 was kind of cathartic.
Found a good recurrence relationship (where solving for q(n) requires solving for smaller values. Was running into an issue where it was running immensely slow. Smaller values than 70 were running almost instantly. Larger values didn't seem to be finishing. I ran it for like 10 minutes and it never finished.
Added a hashmap to store older results, but it wasn't having the expected performance improvement.
Went to bed at midnight. 5 minutes later, had a feeling that I was checking inputs against the outputs, instead of checking inputs against previous inputs.
Fixed that. It ran nearly instantly even for very large values, and immediately showed that it solved all the test cases. Whereas before google would hang for a good minute before telling me several cases failed.
Actually gave me similar feelings to beating a Dark Souls boss.