Singapore PM writes his own Sudoku solver

We’ve seen plenty of politicians with opinions on video games, whether they love them or hate them, but Singapore’s Prime Minister has just trumped them all. Lee Hsien Loong has written his own Sudoku-solving program, posted the source code to Facebook, and asked for bug reports.

Singapore Prime Minister Lee Hsien Loong

Singapore Prime Minister Lee Hsien Loong

Late last month, Lee gave a speech to a group of IT industry leaders, mentioning that his children work in the industry, with two of them graduating from MIT. He also reminisced about his own background in programming:

The last program I wrote was a Sudoku solver in C++ several years ago, so I’m out of date.

Lee Hsien Loong's Sudoku Solver

Lee Hsien Loong’s Sudoku Solver

Unsurprisingly, following the revelation, Lee was bombarded by requests to see the code for his program – prompting the Prime Minister to share his handiwork with the masses. He shared a screenshot to Facebook and a link to a Google Drive folder, which contains the source code, an output sample, and a DOS command line executable, everything you need to get it running or start bug-finding.

“Please tell me if you find any bugs!” Lee urged his fans.

The program is pretty basic: it runs at the command prompt, in a DOS window. Type in the data line by line (e.g. 1-3-8—6), then the solver will print out the solution (or all the solutions if there are several), the number of steps the program took searching for the solution, plus some search statistics.

While it seems that Prime Minister Lee’s future is firmly in politics for now, he’s not ruling out a return to programming. One of his children has even encouraged it, presenting the PM with a textbook on the Haskell programming language. “One day,” laughed Lee, “that will be my retirement reading”.

Tags: , , , , , , , , , ,

Facebook Google+ Linkedin Pinterest Reddit Stumbleupon Tumblr N4G Twitter