Vivian Balakrishnan translates PM Lee's sudoku solver to another programming language

SINGAPORE - Minister for the Environment and Water Resources Vivian Balakrishnan on Tuesday night posted on Facebook his own version of a program that solves sudoku puzzles, about a week after Prime Minister Lee Hsien Loong posted the source code for his sudoku solver.

"Translated PM Lee Hsien Loong's sudoku solver from C++ to Javascript. Trying to learn a new language. Never realised I would actually miss the static typing of C," he wrote.

C, C++ and Javascript are popular programming languages used to create such code. His sudoku solver does a backtrack search to generate only the first solution for now, Dr Balakrishnan added. He provided a link to his blog,, where the solver can be found.


Dr Balakrishnan used the hashtag #SmartNation, as did PM Lee, referring to a Government initiative to explore ways to use technology to achieve social and economic objectives.

PM Lee was commended for being "cool", "awesome" and "amazing" after posting his source code on his Facebook page on May 4.

According to two university staff, Associate Professor Ng Wee Keong, Associate Chair of Research at Nanyang Technological University's School of Computer Engineering, and senior lecturer Aaron Tan from the School of Computing in the National University of Singapore, who are both well-versed in code, PM Lee's code was well-written, and well-structured.

Join ST's WhatsApp Channel and get the latest news and must-reads.