The Cash Register algorithm is one of the only algos I kept getting stuck on and because it was a requirement for the JS cert I committed to solving it over the last couple of days.
For context, I last really got stuck into the algos about 18 months ago. Since then I sit down to try cash register every month or so and give up frustrated after about 45 mins in a complete muddle about what I think I’m trying to do.
Finally, FINALLY, last night at about 12:30am I got all the tests to pass and claimed the cert
Moral of the story:
If you feel like a failure for giving up, know that you can always come back to it later. You might repeat that cycle for a long time, but eventually you will figure it out.
Also, floating point math in JS sucks.