Well if we are showing off sudoku solvers, it would be a sin not to share this one:<p><pre><code> sudoku(Rows) :-
length(Rows, 9),
maplist(same_length(Rows), Rows),
append(Rows, Vs), Vs ins 1..9,
maplist(all_distinct, Rows),
transpose(Rows, Columns),
maplist(all_distinct, Columns),
Rows = [As,Bs,Cs,Ds,Es,Fs,Gs,Hs,Is],
blocks(As, Bs, Cs),
blocks(Ds, Es, Fs),
blocks(Gs, Hs, Is).
blocks([], [], []).
blocks([N1,N2,N3|Ns1], [N4,N5,N6|Ns2], [N7,N8,N9|Ns3]) :-
all_distinct([N1,N2,N3,N4,N5,N6,N7,N8,N9]),
blocks(Ns1, Ns2, Ns3).
</code></pre>
While not <i>one</i> line, to me it is pareto optimal for readable, elegant, and incredibly powerful thanks to the first class constraint solvers that ship with Scryer Prolog.<p>If you want to learn more about it or see more of Markus's work:<p><a href="https://www.metalevel.at/sudoku/" rel="nofollow">https://www.metalevel.at/sudoku/</a><p><a href="https://youtu.be/5KUdEZTu06o" rel="nofollow">https://youtu.be/5KUdEZTu06o</a><p>More about Scryer Prolog (a modern , performant, ISO-compliant prolog written mostly in rust)<p><a href="https://www.scryer.pl/" rel="nofollow">https://www.scryer.pl/</a><p><a href="https://github.com/mthom/scryer-prolog">https://github.com/mthom/scryer-prolog</a>