Complementing Binary Numbers Medium

+100 PTS

Before you start the test, check out our tutorial challenge

  • TYPE CODE PRACTICE CHALLENGE
  • LANGUAGES JAVASCRIPT, PHP, PYTHON, PYTHON2 AND 3 MORE
    LANGUAGES JAVASCRIPT, PHP, PYTHON, PYTHON2, RUBY, SWIFT, TYPESCRIPT
  • TIME ~25MIN

Complementing Binary Numbers

Challenge outline

Hello and welcome to the challenge!


Write a code which receives a string with characters 0, 1 and ? and returns all possibilities of replacing ? characters with 0 or 1.

Example

  • solve('0?1') -> ['011', '001']

Input

  • a string with characters 0, 1 and ?

Output

  • an array concaining all possible ways of complementing the given string

Constraints

  • 0 < length of the given string < 100
  • 0 < amount of ? characters in the given string < 10


You can solve this programming contest in Ruby, JavaScript, Python and many other languages. If you want, you can also take part in other October 2019 competitions. Below you can find some of them:



Have fun and good luck! :)