def splt(s): switch = s[0] out = switch for i in xrange(1, len(s)): if s[i] == switch: out += s[i] else: out += ' '+s[i] switch = s[i] return out def main(): n = 20 m = 0 o = '0' print'0 0' while m < n: m += 1 r = splt(o).split() o = '' for x in r: c = bin(len(x))[2:] v = x[:1] o += c+v print`m`,o print "Done!" if __name__=="__main__": main()
Standard input is empty
0 0 1 10 2 1110 3 11110 4 100110 5 1110010110 6 111100111010110 7 100110011110111010110 8 1110010110010011011110111010110 9 1111001110101100111001011010011011110111010110 10 1001100111101110101100111100111010110111001011010011011110111010110 11 11100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110 12 111100111010110011100101101001101111011101011001110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 13 1001100111101110101100111100111010110111001011010011011110111010110011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 14 111001011001001101111011101011001001100111101110101101111001110101101110010110100110111101110101100100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 15 111100111010110011100101101001101111011101011001110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 16 1001100111101110101100111100111010110111001011010011011110111010110011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110011110011101011001110010110100110111101110101100111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 17 1110010110010011011110111010110010011001111011101011011110011101011011100101101001101111011101011001001100111101110101100111100111010110111001011010011011110111010110111100111010110011100101101001101111011101011011100101100100110111101110101101001100111101110101101111001110101101110010110100110111101110101100100110011110111010110011110011101011011100101101001101111011101011001111001110101100111001011010011011110111010110111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101100111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 18 1111001110101100111001011010011011110111010110011100101100100110111101110101101001100111101110101101111001110101101110010110100110111101110101100111001011001001101111011101011001001100111101110101101111001110101101110010110100110111101110101101001100111101110101100111100111010110111001011010011011110111010110111100111010110011100101101001101111011101011011100101100100110111101110101101001100111101110101101111001110101101110010110100110111101110101100111001011001001101111011101011001001100111101110101101111001110101101110010110100110111101110101100100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011001111001110101100111001011010011011110111010110111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101100111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 19 10011001111011101011001111001110101101110010110100110111101110101100111100111010110011100101101001101111011101011011100101100100110111101110101101001100111101110101101111001110101101110010110100110111101110101100111100111010110011100101101001101111011101011001110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110111001011001001101111011101011001001100111101110101101111001110101101110010110100110111101110101101001100111101110101100111100111010110111001011010011011110111010110111100111010110011100101101001101111011101011011100101100100110111101110101101001100111101110101101111001110101101110010110100110111101110101100111100111010110011100101101001101111011101011001110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110111001011001001101111011101011001001100111101110101101111001110101101110010110100110111101110101100100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011001111001110101100111001011010011011110111010110111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101100111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 20 111001011001001101111011101011001001100111101110101101111001110101101110010110100110111101110101100100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110010011001111011101011001111001110101101110010110100110111101110101100111100111010110011100101101001101111011101011011100101100100110111101110101101001100111101110101101111001110101101110010110100110111101110101101111001110101100111001011010011011110111010110011100101100100110111101110101101001100111101110101101111001110101101110010110100110111101110101101110010110010011011110111010110010011001111011101011011110011101011011100101101001101111011101011010011001111011101011001111001110101101110010110100110111101110101101111001110101100111001011010011011110111010110111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011001001100111101110101100111100111010110111001011010011011110111010110011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110011110011101011001110010110100110111101110101100111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110111100111010110011100101101001101111011101011001110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110111001011001001101111011101011001001100111101110101101111001110101101110010110100110111101110101100100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011001111001110101100111001011010011011110111010110111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101100111001011001001101111011101011010011001111011101011011110011101011011100101101001101111011101011011100101100100110111101110101100100110011110111010110111100111010110111001011010011011110111010110100110011110111010110011110011101011011100101101001101111011101011011110011101011001110010110100110111101110101101110010110010011011110111010110100110011110111010110111100111010110111001011010011011110111010110 Done!