Skip to main content
added 621 characters in body
Source Link
Wrzlprmft
  • 2.9k
  • 21
  • 36

Python – 234234 201

# example for defining lists and n
l=[[1,2,3,4],
     [5],
   [6,7,8,9]]
n=1

# counting code
j=1j
r=[1m=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]j][n]*(k-(len(u)-1)/2+j*i)==x+y*j]for y in M]
m=maxprint[x for x in d if x]

Ungolfed Version

rotation = [1,1+1j,1j,1j-1,-1,-1j-1,-1j,1-1j][n]
m = max(map(len,l))*len+len(l)*9
M=rangeoutput = []
for y in range(-m,m)
D=[]:
for y in M:
 d=[]line = []
    for x in Mrange(-m,m):
        for i,usublist in enumerate(l):
            for k,ventry in enumerate(usublist):
                if r*rotation * ( k-(len(usublist)-1)/2+1j*i2 + i*1j )==x+y*1j == x + y*1j:d+=[v]
                    line += [entry]
    if dline != []:D+=[d]
        output += [line]
print Doutput

Preliminary answer, as I haveThis uses that multiplication (of a complex number) by a complex number corresponds to do other stuff now. I will likely further golf this down later todayrotating and stretching. The value of m[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 a blatant overestimationagain integer complex.

Python – 234

j=1j
r=[1,1+j,j,j-1,-1,-j-1,-j,1-j][n]
m=max(map(len,l))*len(l)*9
M=range(-m,m)
D=[]
for y in M:
 d=[]
 for x in M:
    for i,u in enumerate(l):
     for k,v in enumerate(u):
      if r*(k-(len(u)-1)/2+1j*i)==x+y*1j:d+=[v]
 if d:D+=[d]
print D

Preliminary answer, as I have to do other stuff now. I will likely further golf this down later today. The value of m is a blatant overestimation.

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]

Ungolfed Version

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.

Source Link
Wrzlprmft
  • 2.9k
  • 21
  • 36

Python – 234

j=1j
r=[1,1+j,j,j-1,-1,-j-1,-j,1-j][n]
m=max(map(len,l))*len(l)*9
M=range(-m,m)
D=[]
for y in M:
 d=[]
 for x in M:
    for i,u in enumerate(l):
     for k,v in enumerate(u):
      if r*(k-(len(u)-1)/2+1j*i)==x+y*1j:d+=[v]
 if d:D+=[d]
print D

Preliminary answer, as I have to do other stuff now. I will likely further golf this down later today. The value of m is a blatant overestimation.