SZ = 33 s = [ [ 0 for _ in xrange(SZ+1) ] for _ in xrange(SZ+1) ] s[0][1] = 1 for r in xrange(SZ-1): for c in xrange(1, SZ): s[r+1][c] = s[r][c] ^ s[r][c-1] print '\n'.join(''.join('*' if s[r][c] else ' ' for c in xrange(1, SZ)) for r in xrange(SZ-1))