Answer:
A python program was used for this given question to complete the function binary_strings(string: str) -> Generator[str, None, None].
binary_strings accepts a string of 0's, 1's, and X's and returns a generator that goes through all possible strings where the X's could be either 0's or 1's
Step-by-step explanation:
Solution:
PYTHON CODE:
def binary_strings(string):
binary_string = list(string) # Converting To List
Generator(binary_string,0) # Calling The Recursive Generator Function
''' Recursive Function To Generate All Binary Strings
Formed By Replacing Each 'X' Character By 0 Or 1 '''
def Generator(binary_string,index):
if index == len(binary_string):
print(''.join(binary_string))
return
if binary_string[index] == "X":
# Replace 'X' By '0' And Call Recursively For Next Index
binary_string[index] = '0'
Generator(binary_string, index + 1)
# Replace 'X' By '1' And Call Recursively For Next Index
binary_string[index] = '1'
Generator(binary_string, index + 1)
binary_string[index] = 'X'
else:
# If The Character At A Particular Index is Not 'X' Then
# Calling For Function For Next Index
Generator(binary_string, index + 1)
# Driver code
string = input()
binary_strings(string)