Although PM Lee described his program as written in C++, and the source file having the requisite “cpp” extension, the contents are really in plain C. There were no C++ features used in the program. The program does, in fact, compile with the standard “gcc” command. I suppose the busy man must have gotten a little mixed up with the language he had used.
This program compiles not just without errors, but also without any compile warnings. I know of many programmers who couldn’t care to write programs that compile perfectly, without warnings whatsoever.
PM Lee’s Sudoku solver program is fairly straightforward. The entire program source is just 223 lines long. The PM isn’t very generous with his source code comments. Like me, perhaps. I often joke that my code is the documentation. That way, my documentation is always correct, and up-to-date.
I’ve tested PM Lee’s program with a sample Sudoku puzzle, and I’m pleased to see that the output is legit. The program doesn’t do any error checking though, the onus is on the user to ensure that input is valid. That’s alright, it’s a simple program.
Now, if only our PM can channel his energies to address the concerns and worries of Singaporeans.
Future job applicants to the Singapore civil service, be warned that you may be asked to spit out a Sudoku solver program in Haskell during your interview. Sudoku shall become the benchmark “Hello world” program for testing programmers.