Skip to main content

Practice · 4 of 5

Generate Binary Strings

CHALLENGE
Difficulty: intermediate+25 XP

**Description:** Generate all 2^n binary strings of length n in **lexicographic** order (0 before 1), one per line. n is small enough to enumerate fully. **Input:** One line: n (1 <= n <= 12). **Output:** 2^n lines of n characters each. **Example:** 2 -> 00 / 01 / 10 / 11.

Back to lesson: Practice: Backtracking Problem Set