Generation of Combinatorial Objects · Gray Codes

Lesson 5

Nikolai Chukhin · Alexander S. Kulikov

Programming problem.

Write a program that reads an integer \(2 \le n \le 8\) and prints all binary sequences of length \(n\) such that every two adjacent sequences (as well as the first and the last) differ in at least \(n-1\) positions.

5 points
Public samples
Public sample 1
Input
2
Expected output
00 11 10 01