CSE 130 Fall 2011 - In-Class Exercise 5



Write a python function bitstrings that takes an integer n and returns the list of all strings of 0 and 1 of length n.

>>> bitstrings(1)
[[0], [1]]

>>> bitstrings(2)
[[0, 0], [0, 1], [1, 0], [1, 1]]

>>> bitstrings(3)
[ [0, 0, 0], [0, 0, 1], [0, 1, 0], [0, 1, 1]
, [1, 0, 0], [1, 0, 1], [1, 1, 0], [1, 1, 1]]