import re a=open('../fd/0').read() for d in range(20):d/=2;a=re.sub('x|\.(?=(|[^z]{10})%s)'%~-d,`d`,a[::-1]) print a