X Tutup
Skip to content

Rewrote "Rat in a maze" algorithm + added tests#714

Merged
pomkarnath98 merged 4 commits intoTheAlgorithms:masterfrom
defaude:test/Backtracking/RatInAMaze
Oct 3, 2021
Merged

Rewrote "Rat in a maze" algorithm + added tests#714
pomkarnath98 merged 4 commits intoTheAlgorithms:masterfrom
defaude:test/Backtracking/RatInAMaze

Conversation

@defaude
Copy link
Copy Markdown
Contributor

@defaude defaude commented Oct 2, 2021

Describe your change:

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new JavaScript files are placed inside an existing directory.
  • All filenames should use the UpperCamelCase (PascalCase) style. There should be no spaces in filenames.
    Example:UserProfile.js is allowed but userprofile.js,Userprofile.js,user-Profile.js,userProfile.js are not
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.

It's based on the previous implementation but offers a better API and is now properly testable, too
@pomkarnath98
Copy link
Copy Markdown
Member

Again @defaude
If the algorithm is working fine, then no need to modify it. Someone from the team has already approved and merged by reviewing it.
Moreover, don't create test cases for other's files. Try to create PR with a new Algorithm problem.

@defaude
Copy link
Copy Markdown
Contributor Author

defaude commented Oct 3, 2021

Hi @pomkarnath98 :)

As with #713 , I still think contributing test-cases to already-existing algorithms is valid (and wanted).

Regarding my re-write: True, the existing version worked. It was a bit hard to read, though, and even harder to properly test. So I decided to propose a new implementation that improves a few things:

  • more readable (plus more comments)
  • better testability
  • tiny functional change - the new implementation is loosely based on the original but mixes in the "solution matrix" idea from the example at the linked article.
  • at the same time, introduce a few modern JS syntax things (class syntax, private fields, etc) The reason is: newcomers to this repo might stumble upon this, trying to understand the algorithm itself and are learning something about the language itself at the same time :)

@defaude
Copy link
Copy Markdown
Contributor Author

defaude commented Oct 3, 2021

Update: I gave @chiranjeev-thapliyal credit as the original implementation's author in the documentation block 👍

@raklaptudirm
Copy link
Copy Markdown
Member

@defaude Please format your code with standard.js.

@raklaptudirm raklaptudirm added code style issue Failing style checks Reviewed labels Oct 3, 2021
Sadly, standard does not support private fields (yet)
@pomkarnath98 pomkarnath98 removed the code style issue Failing style checks label Oct 3, 2021
@pomkarnath98 pomkarnath98 merged commit b516787 into TheAlgorithms:master Oct 3, 2021
@defaude defaude deleted the test/Backtracking/RatInAMaze branch October 3, 2021 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

X Tutup