Python icon indicating copy to clipboard operation
Python copied to clipboard

feat: Introduce hamming code generator

Open AyushChakraborty opened this issue 1 year ago • 10 comments

Introduced a new .py file which generates 16 bit hamming codes from the given 11 bit input. Additional 5 bits are redundant, used to correct single bit errors within the data bits

Describe your change:

Introduced a new .py file called hamming_code_generator.py which generates 16 bit hamming codes. 5 bits introduced are for redundancy and used to check and correct for a single bit change anywhere in the final 16 bit binary number. Doctests are written and all other rules mentioned in the checklist and README.md file are followed by me.

  • [x] Add an algorithm?
  • [ ] Fix a bug or typo in an existing algorithm?
  • [ ] Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • [ ] Documentation change?

Checklist:

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized.
  • [x] I know that pull requests will not be merged if they fail the automated tests.
  • [x] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • [x] All new Python files are placed inside an existing directory.
  • [x] All filenames are in all lowercase characters with no spaces or dashes.
  • [x] All functions and variable names follow Python naming conventions.
  • [x] All function parameters and return values are annotated with Python type hints.
  • [x] All functions have doctests that pass the automated testing.
  • [x] All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • [x] If this pull request resolves one or more open issues then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

AyushChakraborty avatar Oct 06 '24 12:10 AyushChakraborty

will change the names of x, y to temp_bit1, temp_bit2

AyushChakraborty avatar Oct 06 '24 12:10 AyushChakraborty

made the lines in the docstring shorter, imported modules according to the specified norm and added k values to a list and used membership operation instead of checking the values of k individually in one of the if statements

AyushChakraborty avatar Oct 06 '24 13:10 AyushChakraborty

@jeffreyyancey added the appropriate changes

AyushChakraborty avatar Oct 08 '24 04:10 AyushChakraborty

The only concern I have left is that it doesn't appear your are enforcing that the number that comes in contains only "0" or "1" characters. It appears to just be converting any character that isn't a "0" to 1. So a string like "#&! & ((30qhjj1+" would be accepted and become 1111111110111111.

jeffreyyancey avatar Oct 08 '24 14:10 jeffreyyancey

The only concern I have left is that it doesn't appear your are enforcing that the number that comes in contains only "0" or "1" characters. It appears to just be converting any character that isn't a "0" to 1. So a string like "#&! & ((30qhjj1+" would be accepted and become 1111111110111111.

Oh yes, I completely overlooked this, thanks I'll make the changes.

AyushChakraborty avatar Oct 08 '24 15:10 AyushChakraborty

Updated the code, can you, if possible merge the PR now?

AyushChakraborty avatar Oct 08 '24 16:10 AyushChakraborty

@jeffreyyancey implemented the pop method

AyushChakraborty avatar Oct 09 '24 05:10 AyushChakraborty

@jeffreyyancey this is actually my first open source contribution, so do you have any idea how the PR can be accepeted into the main repo?

AyushChakraborty avatar Oct 09 '24 17:10 AyushChakraborty

I believe that one of the admins needs to give their approval. Approvals from other users will not allow merging. Instead, it helps find any issues prior to one of the individuals with the rights to approve for merging to view.

jeffreyyancey avatar Oct 09 '24 22:10 jeffreyyancey

Ok got it, thanks for the help

AyushChakraborty avatar Oct 15 '24 04:10 AyushChakraborty