Site icon Zit Seng's Blog

PM Lee Has Confused C With C++

PM Lee's Sudoku programI think our Singapore Prime Minister, Lee Hsien Loong, must have recently gotten a new social media team. Quite notably, of late, his social media posts have been clever, witty, and popular. His recent sharing of his Sudoku program source code, for example, has caught on with international media, even including the techie ones like Arstechnica.

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.

Exit mobile version