Read a positive natural number n. Generate and print in lexicographic
order all binary strings (composed only of the digits 0 and 1) of
length n that contain no two consecutive 1 digits.
Read a positive natural number n. Generate and print in lexicographic
order all binary strings (composed only of the digits 0 and 1) of
length n that contain no two consecutive 1 digits.
The program reads from standard input a single natural number, `n`. - `1 <= n <= 10`
The program prints all strings that satisfy the condition, one per line, in lexicographic order (with `0` before `1`). The digits of each string are printed with no spaces between them.
3
000 001 010 100 101
Use the Get Hint button in the action bar to reveal a guided hint.
No comments yet. Be the first to start the discussion!
3
000 001 010 100 101
Community solutions unlock after you submit a passing solution. Don't peek.
Create a free account to write code, submit solutions, and track your progress.