Singapore’s prime minister shares his C++ Sudoku solver code

Lee Hsien Loong, who studied computer science in college, has shared a program he wrote several years ago to solve Sudoku puzzles

Singapore's Prime Minister Lee Hsien Loong speaking at a podium

Singapore's Prime Minister Lee Hsien Loong.

Credit: REUTERS/Edgar Su

While it seems like software developers have taken over the world, one arena where they’re still relatively rare is politics. As I wrote last year, for example, it’s still hard to find people in the U.S. Congress who have backgrounds as programmers. However, it turns out that at least one country in the world, Singapore, has a former programmer as a prime minister, and he’s actually shared some code to demonstrate his chops.

Lee Hsien Loong has been Singapore’s prime minister since 2004. He studied math and computer science at Cambridge University’s Trinity College in the U.K. in the early 1970s. His math skills were good enough that he was named a Senior Wrangler, meaning he was the top mathematics undergraduate at Cambridge University. After spending time in the military, he soon found his way into politics, where he has spent the majority of his career.

Several weeks ago, during a speech at the Founders Forum Smart Nation Singapore Reception, Loong said that he used to enjoy programming, and that the last program he wrote was a Sudoku solver in C++. To back that up, earlier today he announced on Facebook and Twitter that his code was available to download. He wrote on Facebook that he wrote the program “several years ago” and that the code does “a backtrack search, choosing the next cell to guess which minimises the fanout.”

The code, including the source and a binary executable, is available on Google Drive. If you have trouble accessing the code from Google Drive, someone has put Loong’s source code up on GitHub, which you can access here.

In that same speech to the Founders Forum Smart Nation Singapore Reception, Loong said that his son, an M.I.T. graduate, had given him a Haskell book, which he plans to read once he’s retired. Who knows, then? There might be more code coming from Loong in the future.

ITWorld DealPost: The best in tech deals and discounts.