def f(a):i=range(len(a[0]));j=range(len(a));b,c,d=map(sorted,zip(*[[x,x+y,x-y]for y in i for x in j if"?"<a[x][y]]));return[[[a[x][y],"#"][(a[x][y]>" ")*(b[0]<=x<=b[-1])*(c[0]<=x+y<=c[-1])*(d[0]<=x-y<=d[-1])]for y in i]for x in j] print('\n'.join(map(''.join,f([" . . . . . . . .",". . . . @ . . . "," . @ . . . @ . .",". . . @ . . . . "," . . . . . @ . .",". . . . . . . . "]))))
Standard input is empty
. . . . . . . . . . # # # # . . . # # # # # . . . . # # # # # . . . # # # # . . . . . . . . . .
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!