22

# 任务

## 例子

1个

``````IN
l=
[[0 , 1 , 2],
[3 , 4 , 5],
[6 , 7 , 8]]
n=1

OUT
[    [0],
[3 , 1],
[6 , 4 , 2],
[7 , 5],
[8]    ]
``````

2

``````IN
l=
[[a , b , c , d],
[e , f , g , h]]
n=2

OUT
[[e , a],
[f , b],
[c , g],
[h , d]]
``````

3

``````IN
l=
[[A , B , C , D , E , F],
[G , H , I , J],
[K , L],
[0 , 8],
[M , N],
[O , P , Q , R],
[S , T , U , V , W , X]]
n=7

OUT
[          [F],
[E],
[D , J],
[C , I],
[B , H , L],
[A , G , K , 8],
[0 , N , R , X],
[M , Q , W],
[P , V],
[O , U],
[T],
[U]          ]
``````

4

``````IN
l=
[[9 , 8 , 7 , 6],
[5],
[4 , 3 , 2 , 1],
[0]        ]
n=3

OUT
[  [0 , 4],
[3],
[2 , 5 , 9],
[1 ,NIL, 8],
[7],
[6],     ]
``````

5

``````IN
l=
[    [Q],
[X ,NIL, Y],
[Z]    ]
n=2

OUT
[    [X],
[Z ,NIL, Q],
[Y]     ]
``````

4

TheDoctor 2014年

1

Wrzlprmft

2014年

8

# Python – 234 201

``````# 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]``````

``````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``````

1

1
@Ourous：让x + iy =（x，y），然后将其乘以1 + i =（1,1），您将旋转45度。
Kyle Kanos 2014年

tkocmathla

@tkocmathla：我没有对此进行测试，但是尝试`else: line += [None]`从最后一行开始在第四行之后添加。
Wrzlprmft