Skip to content

Instantly share code, notes, and snippets.

@shinh
Last active November 1, 2025 00:11
Show Gist options
  • Save shinh/f9f3ea02703ef5b4d91f50960f27501b to your computer and use it in GitHub Desktop.
Save shinh/f9f3ea02703ef5b4d91f50960f27501b to your computer and use it in GitHub Desktop.
def p(n):
i,a,t=min((sum(n,[]).count(r),e,r)for(e,r)in enumerate(sum(n,[])));i,m=max((abs(e-a)+abs(e%len(n[0])-a%len(n[0]))*2,e)for(e,r)in enumerate(sum(n,[]))if r<1)
for e in range(len(n)):
for r in range(len(n[0])):
for g in range(9):
if n[e][r]<1and e-~g*(a//len(n[0]))-m//len(n[0])in range(len(n))and r-~g*(a%len(n[0])-m%len(n[0]))in range(len(n[0])):n[e-~g*(a//len(n[0])-m//len(n[0]))][r-~g*(a%len(n[0])-m%len(n[0]))]=t
return n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment