Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NB. Calculate neighbourhoods
- u=:~."1 b,.c,.r[r=.9#i.9 9[c=.81$|:i.9 9[b=.(,i{9#i.9){i[i=.(]/. i.@#),{;~3#i.3
- NB. Make a guess (based on the cell with the fewest candidates)
- g=:3 :'y+"1(1+I.i{b)*/i=i.81[i=.(i.<./) (+/"1 b){10,}.i.10[b=.(0&=>(1+i.9)e."1 u&{)y'
- NB. Our solve function (also automatically fills in single candidate boxes without guessing)
- s=.(;@:(<@(,:`g@.(0&e.))"1))@:(((27 9$1)-:"2(0&=+.~:"1)@((i,(,|:)i.9 9){"_ 1]))#])@:((+(+/ .*&(1+i.9)*1=+/"1)@(0&=>(1+i.9)e."1 u&{))^:_"1)^:_
- NB. Run solve over the input file and exit
- exit 0[((stdout&(,&(10{a.)"1)&(s&.('.123456789'&i.)))&.>)"0(#~(a:&~:))<;._1(10{a.),((1!:1)2{ARGV)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement