I'm a huge dork. I was fiddling around on repl.it to see if I could use it in next year's AP CS class (hey go volunteer with TEALS!) and I stumbled upon this script from a year ago. Don't judge me too harshly! I don't even know what I was doing or why. After seeing the state it was in, I could not leave it alone. And apparently, I am in a better headspace now because I was able to refactor it fairly quickly and get it into a much better state. I did this heavily utilizing constants and recursion, but I'd be interested to see how others would solve this.
Here is the code if you don't want to bother with the repls:
(open source and trusted by devs everywhere ❤️)