Tetris by rolf

s=[]
for i in range(15):s+=[list(raw_input())]
s+=[['#']*10]
p=[] 
for x in range(10):
 w=[x] 
 for y in range(4):
  if s[y][x]=="#":w+=[y]
 if len(w)>1:p+=[w]
m=99
for q in p:
 x=q[0];r=0;h=q[-1]+1
 while s[h+r][x]==" ":r+=1
 if m>r:m=r
for q in p:
 x=q[0];Y=q[1:]
 for y in Y:s[y+m][x]="#";s[y][x]=" "         
d=-1
for y in range(15,-1,-1):
 if s[y]==["#"]*10:del s[y];d+=1
for i in range(d):s=[[' ']*10]+s
for z in s:print"".join(z)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page