Singapore's Prime Minister Shares His C++ Sudoku Solver Code
itwbennett writes: Several weeks ago, during a speech at the Founders Forum Smart Nation Singapore Reception, Singapore's prime minister Lee Hsien 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 is 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.'
Well... probably more accurate to call that C code. It's compilable under a C++ complier, but offhand I didn't spot anything that really made it C++-specific. Not a knock on the Prime Minister, but it might even be a little more geek cred to call it a Sudoku solver in C.
The guy was a Senior Wrangler (top math undergrad) at Cambridge before going to governance. I would hope he'd have picked up some coding skills along the way.
Now with some other leaders, I'm impressed when they spell their names right.
Its also all legal C++. Just because it doesn't use the advanced features doesn't mean it isn't C++. I'd argue that for something this simple its even better code this way.
I still have more fans than freaks. WTF is wrong with you people?
How's about including a link to the actual code?
Here you go:
https://drive.google.com/folde...
OR:
https://github.com/Doppp/LHL-S...
Nice!
w00t
It might be a 'stupid sudoku solver', like you say, but at least, that is a program that does something, rather than the congress critters who do nothing but producing massive amount of HOT AIR
Muchas Gracias, Señor Edward Snowden !
There should be an international coding competition between heads of state.
but our former prime-minister had a restaurant... our great Greek dinner with mousaka,
Which one? You'd have hoped with that experience he might have had some idea how to balance the books. Did his restaurant go broke?
It was mister Samaras, the one who just lost the elections - (he claims) his restaurant did just fine (he had it years ago, together with a business partner, while studing in USA - yes, one more Greek restaurant in the States!). To be fair he did a good job as a prime minister in the elimination of deficit, he not only balanced the books, but provided a (significant) surplus. Our new prime minister...well...!
Antisthenes: "Wisdom begins by examining the words/names." - excuse my English, i am (slightly...) better with my Greek!
The code resembles something you expect from a first-year programming student - there's an input buffer overflow bug waiting to happen, the array size is odd (80 byte array? why? scanf() is still called without a field length specifier, and you only use 9 of those 80 bytes in a normal case).
You seem to be very optimistic in your views of first year programming students.
Here's what I see: Many years ago, I had a lovely job helping to teach people to program, and I had to review their homework. There were some whose thought processes were all over the place. There was one guy who managed to write the most convoluted code that always worked perfectly well, but I would never have hired him because reviewing it was just too painful. And there was one student who wrote code that I could scan in half a minute and see that it was correct and worked. And that's what this guy's code looks like.
"Perhaps it was written by him in his spare time". OF COURSE it was written in his spare time. His a prime minister, he doesn't write code on the job. What comments do you want? The code is simple and obvious. What data structures to explain? If you are too stupid to understand them immediately, then you shouldn't be programming. What lack of error checking? What scenario do you suggest where error checking would help?
Your last sentence is a totally unfounded, vicious attack on the intellectual honesty of the man. It's disgusting. Unless you have any evidence for it, you should apologise.