Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(hanoi): create exercise #448

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

NikitaRevenco
Copy link
Contributor

@NikitaRevenco NikitaRevenco 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

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

Ready for review!

@MaoShizhong MaoShizhong self-requested a review June 30, 2024 13:25
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/solution/hanoi-solution.spec.js Outdated Show resolved Hide resolved
@NikitaRevenco NikitaRevenco requested a review from MaoShizhong July 3, 2024 18:58
@NikitaRevenco NikitaRevenco changed the title (20) New exercise | Tower of Hanoi feat(hanoi): create exercise Aug 9, 2024
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/README.md Outdated Show resolved Hide resolved
20_hanoi/solution/hanoi-solution.js Outdated Show resolved Hide resolved
@MaoShizhong MaoShizhong 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.

20_hanoi/hanoi.spec.js Outdated Show resolved Hide resolved
Co-authored-by: MaoShizhong <[email protected]>
20_hanoi/README.md Outdated Show resolved Hide resolved
@MaoShizhong MaoShizhong requested a review from JoshDevHub August 25, 2024 16:16
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.

2 participants