Hanoi
- 4 Devlogs
- 9 Total hours
A utility to solve the Tower of Hanoi.
A utility to solve the Tower of Hanoi.
I finally got all the Action working except for Windows (macOS, Linux, and documentation builds), and the Windows Swift installer was not cooperating. I eventually decided to remove the precompiled Windows .exe. Windows users, you’ll have to compile it yourself. At some point in the future I might figure out how to fix the Windows Swift installer. I’ve spent much more time working on this since the last devlog than it says here. I guess Wakatime didn’t track my debugging. (I’m not trying to ask for more Stardust; just trying to let y’all know it was hard to get this working)
I got the README.md and tests written! Now I’m having the issue that my GitHub Action, which is meant to build a binary for macOS, Linux, and Windows, generate a changelist, make a release with the changelist and binaries, and build and deploy the documentation to my server, keeps failing (it’s the building the binary part that fails). I’ve tried at least 6 majorly different versions of the Action, and for most of those (all but one) I’ve deleted the GitHub repo, made a new one, added the
secrets, deleted and reinitialized the .git dir on my machine, commited and the code, and made and pushed the tag? I know it’s not necessary to do all that, but it (the Action) would be kinda glitchy when I didn’t, and it felt better to completely restart the Git history. It’s so frustrating to be so close to making the repo public and shipping here on Stardust just to get blocked by GitHub itself, but I’m hopeful that I’ll get it working sometime soon.
I’ve got the algorithm fixed! It turns out the old version was too complicated. It was flipping which stack it moved pieces to when the count variable was an odd number, which was unnecessary. I’ve also moved the majority of the code into a package build target, so other people will be able to import it and use my structure and algorithm implementation. I’ve made the CLI tool more than just a test. Now I just need to write a README.md and add a few more tests, and I’ll be ready to ship!
I’m writing a CLI tool to solve the Tower of Hanoi puzzle/game in Swift.
I finished up writing classes for the Game, Stacks, and Pieces.
Now I’m in the middle of writing the algorithm to solve the game. It
seems to break when the recursive Stack.move method’s counter (the
variable that’s decremented and passed to the recursive function/method)
gets to 1.
The logs should start with
[[1, 2, 3, 4], [0], [0]]
[[2, 3, 4], [1], [0]]
[[3, 4], [1], [2]]
[[3, 4], [0], [1, 2]]
[[4], [3], [1, 2]]
[[1, 4], [3], [2]]
[[14], [2, 3], [0]]
and continue on.
Instead they say
[[1, 2, 3, 4], [], []]
[[2, 3, 4], [1], []]
[[3, 4], [], [1, 2]]
[[4], [1, 3], [2]]
and stop (see attached screenshot).