algorithms icon indicating copy to clipboard operation
algorithms copied to clipboard

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

Open Simranstha045 opened this issue 1 year ago • 0 comments

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.

Simranstha045 avatar Oct 19 '24 06:10 Simranstha045