Computational nanoscientist Surendra Jain has written solvers for Sudoku,
Killer Sudoku, Samurai Sudoku, Calcudoku, Kakuro and many other
logic problems.
All are elegantly coded and very fast: for example,
the "World's Hardest Sudoku" is solved in 0.05 seconds (on a 5 year
old PC) and his Knight's Tour solver is an order of magnitude faster
than this one.
The page (called "Classical Geek") has all source (in Fortran 90,
one of the most popular languages in high-performance computing)
as well as compilation and running instructions.
(Score: 2) by Nerdfest on Wednesday July 02 2014, @12:42PM
I had a look at the source code for a few. This is obviously some meaning of the word "elegant" I wasn't previously aware of. They're reasonable clean and well formatted solutions, but I'd be very hard-pressed to call them elegant. In general, I don't think purely procedural languages are not made for 'elegant' solution. Fast? Sure. Straight-forward? If well written, yes, but they generally end up being longer than more 'elegant' solutions in object oriented or functional languages. That's not to say those approaches are necessarily better. If you're not careful, elegant can drop off the cliff to obscure.
(Score: 2, Funny) by middlemen on Wednesday July 02 2014, @01:35PM
The summary means "elegant FORTRAN" not "any" elegant code in general. FORTRAN code can look really ugly and like Python needs a lot of formatting !
The most elegant code to solve Sudoku in my fictional language titled "sudokoo" is as below:
solve sudoku || sudo solve sudoku
(Score: 2, Interesting) by Anonymous Coward on Wednesday July 02 2014, @01:41PM
Yeah except it's written in F90 so it doesn't need fixed-form formatting at all, and it isn't written FORTRAN but Fortran. The formatting requirements for "modern" Fortran -- and it's stretching it a bit to describe a 15 year old standard as modern -- are barely more stringent than those for C or C++. One can write perfectly elegant programs in F90 and beyond, so long as one's view of "elegance" doesn't rule out "end if" and "end do" statements.