# Python – <s>234</s> 201 <!-- language: lang-python --> # example for defining lists and n l=[[1,2,3,4], [5], [6,7,8,9]] n=1 # counting code j=1j m=max(map(len,l))+len(l) M=range(-m,m) e=enumerate d=[[v for x in M for i,u in e(l)for k,v in e(u)if[1,1+j,j,j-1,-1,-j-1,-j,1-j][n]*(k-(len(u)-1)/2+j*i)==x+y*j]for y in M] print[x for x in d if x] **Ungolfed Version** <!-- language: lang-python --> rotation = [1,1+1j,1j,1j-1,-1,-1j-1,-1j,1-1j][n] m = max(map(len,l))+len(l) output = [] for y in range(-m,m): line = [] for x in range(-m,m): for i,sublist in enumerate(l): for k,entry in enumerate(sublist): if rotation * ( k-(len(sublist)-1)/2 + i*1j ) == x + y*1j: line += [entry] if line != []: output += [line] print output This uses that multiplication (of a complex number) by a complex number corresponds to rotating and stretching. `[1,1+1j,1j,1j-1,-1,-1j-1,-1j,1-1j]` are complex numbers corresponding to the required angles and using the smallest scaling factor such that for an integer complex input the output is again integer complex.