I am new to C++, and I need to write a code that can find a binary code by checking a bitset against inputs and excluding unnecessary options.
Example:
input-000000000 = 6 correct
This implies that there must be 3 ones present.
I need the code to only use strings that contain 6 zeros and three ones and print one attempting to narrow down the code.
Example:
000000111 = 5 correct
This must mean that two of those ones are correct and one must be a zero with a one somewhere in the first six digits.
How do I approach this problem?
I have so far the function:
string index2code (int i)
{
return bitset <9>(i).to_string();
}
But I am still struggling to think of the logic, and how to use it.