Source

yt.geometry_tests / bittwiddle.py

import itertools

i = 105231
h = 555358
h = 1146360

#h, i = 1146365, 105231
#h, i = 555355, 105231
#h, i = 1790047, 105231
#i -= 1
#h += 1

vals = []
bywise = []
flippy = []
for var in [i, h]:
    a = []
    tot = 0
    for j in range(27):
        v = ((var >> j) & 1)
        tot += v
        a.append(str(v))
    vals.append("".join(a[::-1]))
    bywise.append( [vals[-1][0::3],
                    vals[-1][1::3],
                    vals[-1][2::3]] )
    flippy.append("".join(itertools.chain(bywise[-1][::-1])))
    print
    print "".join(['abc']*9)
    print vals[-1], tot
    print "".join(['a']*9 + ['b']*9 + ['c']*9)
    print