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

Implement Gray Code Generator with Unit Tests for n-bit Sequences #932

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Simranstha045
Copy link

Description:

This pull request adds the gray_code(n) function and corresponding unit tests to generate and verify n-bit Gray code sequences. Gray code is a numeral system used in digital systems where two successive values differ by only one bit.

Key Features:

  • Gray Code Generator:

    • The function recursively generates Gray codes for any n-bit length by building on previous sequences and mirroring them.
    • Returns Gray code in decimal representation.
  • Comprehensive Unit Tests:

    • A set of unit tests is included to validate the correctness of the Gray code generator for various bit lengths.
    • Tests for 0-bit, 1-bit, 2-bit, 3-bit, and 4-bit Gray code sequences, ensuring accuracy of the output.

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