{"id":20144226,"url":"https://github.com/made2591/go-hanoi","last_synced_at":"2025-06-23T04:36:23.575Z","repository":{"id":57609509,"uuid":"98760475","full_name":"made2591/go-hanoi","owner":"made2591","description":"The famous Hanoi game written in Go. Thanks to @skelterjohn for his lib, go-matrix, that you can find in https://github.com/skelterjohn/go.matrix","archived":false,"fork":false,"pushed_at":"2017-07-30T09:35:24.000Z","size":213,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-02T23:44:09.843Z","etag":null,"topics":["algorithm","classical","exercise","game","go","hanoi","hanoi-riddle","hanoi-towers","math","problem","recursion"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/made2591.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-29T21:50:37.000Z","updated_at":"2020-04-25T07:23:04.000Z","dependencies_parsed_at":"2022-08-27T11:32:04.820Z","dependency_job_id":null,"html_url":"https://github.com/made2591/go-hanoi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/made2591/go-hanoi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-hanoi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-hanoi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-hanoi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-hanoi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/made2591","download_url":"https://codeload.github.com/made2591/go-hanoi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/made2591%2Fgo-hanoi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261416265,"owners_count":23155036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","classical","exercise","game","go","hanoi","hanoi-riddle","hanoi-towers","math","problem","recursion"],"created_at":"2024-11-13T22:09:18.857Z","updated_at":"2025-06-23T04:36:18.562Z","avatar_url":"https://github.com/made2591.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Go-Hanoi\n\nThe famous Hanoi game written in Go. To test some configurations, from a shell:\n\n```shell\ngo get github.com/skelterjohn/go.matrix\ngit clone https://github.com/made2591/go-hanoi\ncd go-hanoi\ngo run main.go\n```\n\nMoves will be printed in stdout, with scores (number of) in the end. Below an execution gif with 6 disks:\n\n\u003cp\u003e\n\t\u003cimg src=\"./hanoi_ex.gif\" width=\"50%\"/\u003e\n\u003c/p\u003e\n\n## Dependencies\n\nThe only external used is the following:\n\n```shell\ngo get github.com/skelterjohn/go.matrix\n```\n\nThanks to [skelterjohn](https://github.com/skelterjohn/) for his lib. I think I will contribute soon because I'm truly interested (see [go-perceptron-go](https://github.com/made2591/go-perceptron-go)). I was just bored XD (this fu****ng tricky game drived me crazy), of course you can use primitive...\n\n## Notes about pretty print\n\nIt might seem easy to make a version of Hanoi in Go. And it is. My initial plan was to learn how to print in place multiline-string in go. Then problem became \"how can I pretty print a generic Hanoi configuration?\", such as [2, 1, 0]. After some tests, I realized that the best Hanoi representation is the matrix form.\n\nSo I looked for a matrix lib on github and found [go.matrix](https://github.com/skelterjohn/go.matrix) to be good enought for my needs (just a easy/ready-to-use matrix representation). I think I will go throught this repository because I found some foundamentals missing (projections, max, sum, etc). Back to my problem...how could you define f([][]) to return strings like the one above? \n\n```shell\n|--------------------------|\n|   **   |        |        |  \n|  ****  |        |        |  \n| ****** |        |        |  \n|--------------------------|\n\n|--------------------------|\n|        |        |        |  \n|        |        |   **   |  \n| ****** |        |  ****  |  \n|--------------------------|\n\n|--------------------------------------|\n|            |            |            |  \n|            |            |            |  \n|            |            |            |  \n|  ********  |            |     **     |  \n| ********** |   ******   |    ****    |  \n|--------------------------------------|\n```\n\nThe answer is simple: DON'T try to collapse positions and dimensions in one-dimensional struct. Instead, procede creating a matrix form with a drawcell function as defined above. With a little of linear algebra you should understand the logic behind: the point is find relations between average point, doubling disk dimension and user mean to center disk in columns (see ```func cell```) and please feel free to ask.\n\n## Improvements\n\n- Realize a better-performance version of Hanoi solver if there are more than one ```auxiliary``` columns.\n- Introduce check-errors for setup (actually, index of columns are not cheked)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmade2591%2Fgo-hanoi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmade2591%2Fgo-hanoi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmade2591%2Fgo-hanoi/lists"}