You are browsing as a guest. Sign up (or log in) to start making projects!

Hanoi

  • 4 Devlogs
  • 9 Total hours

A utility to solve the Tower of Hanoi.

Ship #1

I made a command-line utility that helps you solve the Tower of Hanoi puzzle! Partway through I realized that my game structure, logic, and algorithm could be used in other applications too, so I added a package target. You can add .package(url: "https://github.com/jackr4bbit/Hanoi", from: "1.0.0") to your Package.swift to use it in your own Swift project! To use my CLI tool, just download the binary for your platform from the GitHub Releases page, make it executable with chmod +x path/to/download, and move it to somewhere on your path (like /usr/local/bin), or clone the repo and run swift build -c release --product hanoi.

  • 4 devlogs
  • 9h
  • 3.07x multiplier
  • 27 Stardust
Try project → See source code →
Open comments for this post

1h 47m 38s logged

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)

0
0
12
Open comments for this post

1h 25m 21s logged

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.

0
0
7
Open comments for this post

2h 58m 53s logged

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!

0
0
4
Open comments for this post

2h 32m 59s logged

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).

0
0
12

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…