Skip to content

Instantly share code, notes, and snippets.

View thfm's full-sized avatar

Tom Freeman thfm

  • Sydney University
  • Australia
View GitHub Profile
@thfm
thfm / golfed.py
Last active December 7, 2023 01:10
Sudoku Solver (576 bytes)
import copy
e,z=enumerate,range
def s(b):
l=[(x,y)for y,r in e(b)for x,c in e(r)if c==0]
if len(l)==0:
return b
x,y=l[0]
for g in set(z(1,10))-set(b[y]+[r[x]for r in b]+[c for i in z(y//3*3,y//3*3+3)for c in b[i][x//3*3:x//3*3+3]])-{0}:
b[y][x]=g
n=s(copy.deepcopy(b))