Loading...
Loading...
Loading...
A door panel accepts codes made of the digits 0 and 1. Write a program that reads the code length n and prints every code of that length, in increasing order, one per line. Build the codes with choose, explore, undo.
Example
Input
2
Output
00 01 10 11
Four codes.
Try the problem first. Open one hint at a time.
Keep one list called path. Add a digit, call the function again, then remove the digit.
When the path has n digits, print it and return. Try 0 before 1 so the codes come out in order.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor