Computer Science, asked by samriddhi1699, 4 months ago

Given a string made up of 0, 1 and ?, where ? acts as
a wildcard character which can be replaced by either
0 or 1, print the number of all possible combinations
of the string.
For example, if the string is "011?0" then your
program should output 2 (as a set of all strings,
which are: ["01100", "01110"]).
Input Format: String consisting only of the characters
0,1 and ?
Output Format: An integer denoting number of all
possible combinations of the string
Sample Test Case
Input
0?0
Output
2

Answers

Answered by ykumar34
0

Answer:

def possiblecomb(s):

#assuming that string s contains only 0,1, and ?

   n=s.count('?')

   return 2**n

st=input("Enter a string: ")

print(possiblecomb(st))

Explanation:

The code is in Python

The answer is  2^{number of ? in the string}

Similar questions