Skip to content

refactor: simplify HammingDistance #4218

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

Merged
merged 4 commits into from
Jun 21, 2023

Conversation

vil02
Copy link
Member

@vil02 vil02 commented Jun 21, 2023

I have found few problems with the implementation of HammingDistance, namely:

  • unnecessary conversion from String to byte[],
  • I think that this implementation was aiming to handle only Strings containing only 0s and 1s, but this is not checked anywhere.

This PR:

  • makes a proper utility class out of HammingDistance in 610def7,
  • simplifies logic of some existing tests and adds tests against empty input and input of length 1 in 58f7da3,
  • simplifies logic in class HammingDistance, updates naming and changes the behaviour for non-binary strings in 00d54bd,
  • removes redundant logging in 32b1243.
  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

@vil02 vil02 marked this pull request as ready for review June 21, 2023 14:58
@debasishbsws debasishbsws merged commit 63739f4 into TheAlgorithms:master Jun 21, 2023
@debasishbsws
Copy link
Member

thank you for your contribution

@vil02 vil02 deleted the refactor_hamming_distance branch June 21, 2023 19:46
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.

2 participants