Back to task

236 symbols python3
Thu Oct 20 03:49:37 2016 Sait2000
N=int(input())
a=lambda r,c,i,j:r==i or c==j or c-j in(r-i,i-r)
z=lambda n:[s+[[n-1,c]]for s in z(n-1)for c in range(N)if~-any(a(*([n-1,c]+q))for q in s)]if n>0else[[]]
print("\n".join(sorted("".join(str(q[1])for q in s)for s in z(N))))


Leave a comment

Parsed as Markdown

Login to leave a comment