Solve a Sudoku grid only using magic, recursion, and 140bytes of brute force.
This entry was inspired and built on top of the itsy bitsy shoulders of the smallest sudoku solvers in Perl (120b), Ruby (122b), Python (178b), ...
Credits go this way:
166b @p01 .......... initial implementation
147b @p01 .......... initial golf
146b @qfox ......... loop optimization
145b @qfox ......... output with closured callback
140b @p01 .......... output with hijacked Array.prototype.toString()
141b @maksverver ... fixed the glitchy j^i==j test
140b @fgnass ....... ReferenceError exit trick + cross browser fix
Thanks to everyone who helped golf and fix this puppy.
The
toString
sugar would definitely count in a JS1K: Every thing counts in JS1K.However things seem a more lax at 140byt.es. See the base64 entries for instance where the whole list of characters is passed as argument ( a whooping 64+ bytes for free ).
That being said, if people are OK with encapsulating the call in a
try/catch
, then we can settle this at 140 bytes with a mix of fgnass ReferenceError trick and maksverver decomposition of the testi!=j && a[j]!=m