Skip to content

Add count distinct primes from binary string algorithm #2970

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

rudrakshtank
Copy link

@rudrakshtank rudrakshtank commented Jul 19, 2025

@realstealthninja Could you please review this PR?

Description of Change

Added count_distinct_primes_from_binary_string.cpp to the bit_manipulation/ directory.

This program counts the number of distinct prime numbers that can be formed from a binary string using:

  • Any permutation of characters (i.e., swapping)
  • Changing '1's to '0's (but not the reverse)

It uses an efficient implementation of the Sieve of Eratosthenes for prime checking and bitmasking to explore all possible combinations.

Includes:

  • Doxygen-style documentation
  • A working main() with an example test case

Contributors guide


Checklist

  • Added description of change
  • File name matches File name guidelines
  • Added test case/example in main()
  • Added Doxygen-style documentation
  • Comments/documentation added as needed
  • PR title follows semantic commit guidelines
  • Confirmed this is not a duplicate contribution
  • I acknowledge that all my contributions will be made under the project's license

Notes:

Efficient bitmask + sieve-based solution to find all valid prime numbers from binary strings using allowed transformations.

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.

1 participant