Write a program that takes two arguments n
and k
and prints all binary strings of length n
that contain k
zero bits, one
per line. The program:
binary.py
itertools
modulezbits(n, k)
that returns a set of stringsRun the following tests to ensure that the program is correct.
import binary
assert binary.zbits(4, 3) == {'0100', '0001', '0010', '1000'}
assert binary.zbits(4, 1) == {'0111', '1011', '1101', '1110'}
assert binary.zbits(5, 4) == {'00001', '00100', '01000', '10000', '00010'}
Commit the binary.py
program to the repository you used for Assignment 3.