Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. def print_combinations(pattern: str):
  2.   """
  3.  Recursively is called to replace the '?' with '0' and '1' and print combinations
  4.  """
  5.   question_pos = pattern.find("?")
  6.   if question_pos == -1:
  7.     print(pattern)
  8.   else:
  9.     for i in ["0", "1"]:
  10.       print_combinations(pattern[0:question_pos] + i + pattern[question_pos+1:])
  11.  
  12. print_combinations("0???1")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement