from random import*L=[[1,0],[1,1]];C=choiceexec"A=C(L);B=C(L);L=[L+[map(int.__xor__,A,B)],[x+[C([1,0])]for x in L]][A==B];"*input()print L
5
[[1, 0, 0], [1, 1, 1], [0, 1, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!