Skip to content

Conversation

@nik-rev
Copy link
Contributor

@nik-rev nik-rev commented Mar 24, 2024

Because

I think this exercise should be the last one because in my mind it's the most difficult one.

This PR

  • Adds exercise 20

Issue

Related to #27265

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project Contributing Guide
  • The title of this PR follows the location of change: brief description of change format, e.g. 01_helloWorld: Update test cases
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If this PR includes any changes that affect the solution of an exercise, I've also updated the solution in the /solutions folder

@nik-rev nik-rev marked this pull request as draft March 24, 2024 16:25
@nik-rev nik-rev changed the title New exercise | Tower of Hanoi (20) New exercise | Tower of Hanoi Mar 24, 2024
@nik-rev nik-rev marked this pull request as ready for review May 3, 2024 00:20
@nik-rev
Copy link
Contributor Author

nik-rev commented May 3, 2024

Ready for review!

@mao-sz mao-sz self-requested a review June 30, 2024 13:25
nik-rev and others added 6 commits July 3, 2024 17:15
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
@nik-rev nik-rev requested a review from mao-sz July 3, 2024 18:58
@nik-rev nik-rev changed the title (20) New exercise | Tower of Hanoi feat(hanoi): create exercise Aug 9, 2024
nik-rev and others added 5 commits August 18, 2024 15:29
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
@nik-rev nik-rev requested a review from mao-sz August 18, 2024 17:34
@mao-sz mao-sz added the Status: Do Not Merge This PR should not be merged until further notice label Aug 20, 2024
Comment on lines 21 to 38
Your task is to create a function, `hanoi(n)`, that when given the number of disks in the starting tower (`n`), will return an array. The first element of this array will be the towers' initial state. The last element will be the towers' final state. Every intermediary element will represent a step to get from the initial position to the final position.

The function **must** return a solution in the minimum number of moves. i.e. there will be no duplicates in the array returned.

For example, `hanoi(3)` will output the Tower of Hanoi solution as a series of steps:

```
[
[[3, 2, 1], [], []],
[[3, 2], [], [1]],
[[3], [2], [1]],
[[3], [2, 1], []],
[[], [2, 1], [3]],
[[1], [2], [3]],
[[1], [], [3, 2]],
[[], [], [3, 2, 1]],
]
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instructions need to be amended to reflect the new requirements of returning an array of strings with the moves - the required string template must be provided as well.

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
@mao-sz mao-sz requested a review from JoshDevHub August 25, 2024 16:16
…be in

Co-authored-by: MaoShizhong <122839503+MaoShizhong@users.noreply.github.com>
@JoshDevHub
Copy link
Contributor

I've got the other PRs mostly ready to go for the Ruby course, so hopefully we can finally get this work merged soon.

The main thing giving me pause right now is this specific exercise, which I'm not entirely sold on for a couple of reasons:

  1. I think it's quite challenging, and I'm not all that interested in putting learners through the ringer on these questions. They really just need to understand recursion well enough to do DFS type things on their Binary Search Trees. I kind of want to stay away from more challenging problem types.
  2. The problem setup/instructions present a more abstract situation than the other problems, which have a pretty clear and logically straightforward (input -> output) setup. With every other problem we give for these exercises, the answer can be known to the learner just from looking at the input and understanding the (quite basic) transformation we want. This one doesn't work that way. Even if you understand the rules, you can't quickly intuit what hanoi(4) should return. I argue that this makes the problem not great for learning recursion.

Willing to be swayed on some of this though if either of you are really set on keeping it around @mao-sz @nik-rev

@mao-sz
Copy link
Contributor

mao-sz commented Nov 10, 2025

@JoshDevHub I don't have a particularly strong opinion on this; your points make a lot of sense. I'm more than happy to defer to your judgement on this 👍

@nik-rev
Copy link
Contributor Author

nik-rev commented Nov 11, 2025

Since we've all come to a consensus, let's get rid of this one!

@nik-rev nik-rev closed this Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Do Not Merge This PR should not be merged until further notice

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants