back to article Singapore's prime minister releases source code for his hand-coded Sudoku-solver

Singaporean prime minister Lee Hsien Loong has decided to reveal the source code of the Sudoku-solving app he personally coded. The PM revealed he likes to program in his spare time last month and mentioned the Sudoku-solver. He's since taken to Facebook to announce the source code dump. “The program is pretty basic,' the PM …

  1. Long John Brass

    Deep work

    Jon Blow did a talk about deep work & how it changes the way you think

    It's probably a good thing if more politicians do this kind of thing ... makes em smarter

    www.youtube.com/watch?v=Lo7cTlaVJdQ

    1. Cliff

      Re: Deep work

      Makes them smarter, but also encourages different ways of approaching a problem and of seeing/modeling the world around them.

      Remember when you were learning Entity Relationship models, or Object Oriented design, you had a week it two is setting the world as tables with attributes or classes with methods? That was your brain making new connections, being able to spot bigger patterns, being, as you say 'smarter'. Smarter in that it'll now, at some level, be just a little bit better at analysing the big-scale picture and seeing flows of information, understanding interfaces, etc.

      I would love some IT enthusiasm in cabinet alongside PPE and the classicists!

    2. Anonymous Coward
      Anonymous Coward

      Re: Deep work

      Do we really want our politicians any smarter?

      There's every danger that if they actually know something, then they might actually do something. Which could be disastrous for all involved.

  2. T. F. M. Reader

    Speaking of snakes...

    ...Reg readers will doubtless wish that the main candidates for prime minister [...] could code a single line of anything...

    I am pretty sure they all can do one line of python:

    pass

  3. Anonymous Coward
    Anonymous Coward

    personally

    I would have used JavaScript myself.

    1. Anonymous Coward
      Anonymous Coward

      Re: personally

      Solving problems like this is no different than solving a Sudoku puzzle. It's a mental challenge for the sake of solving a problem, the language used isn't really relevant. Perhaps he wanted to brush up on his C++?

      1. John Sager

        Re: personally

        +1. I'm not personally interested in Sudoku (though my wife is), but I wrote a Sudoku solver as a way of playing with Knuth's 'Dancing Links'. Then I modded it to find all the solutions to a puzzle called the Bedlam Cube - a 3D pentominoes puzzle. That was a far more interesting challenge than solving any number of Sudoku puzzles. I did puzzle my wife by printing out some 4,5, and 6 squared Sudoku puzzles though:)

  4. OzBob

    The only thing worse than a superior who knows nothing about IT

    is a superior who thinks he knows something about IT.

    1. Anonymous Coward
      Anonymous Coward

      Re: The only thing worse than a superior who knows nothing about IT

      So if the PM can't fit in time for a full degree/proper training, he should be discouraged from learning computing in his free time? That's a strange attitude. Even if this PM never wants to work in IT or write any serious software, learning of any kind should always be encouraged.

    2. Anonymous Coward
      Anonymous Coward

      Re: The only thing worse than a superior who knows nothing about IT

      According to wikipedia Mr. Lee has a 1st in Mathematics from Cambridge, achieving the highest marks for his year (becoming senior wrangler). I suspect he is therefore rather better positioned to understand programming and algorithms than most.

      Of course, I'm sure many other commenters will have tales to tell about what happens when a programmer is promoted to an IT management position, but I personally would prefer a mathematician to a PPE graduate any day of the week.

  5. emmanuel goldstein

    cameron is already out there, weaponized and in the wild. the thought of adding coding to its capabilities is deeply troubling.

  6. ratfox

    Not bad

    I wonder who taught him to declare loop variables at the beginning of the methods, though. That's a style I haven't seen in a long time.

    1. John Sager

      Re: Not bad

      I've always done that - declare before use has been a paradigm of many languages I've programmed in over the decades. I know C++ has 'for (int i=0;...' and many C compilers will support that (is it a formal C language feature now?), but I guess old habits die hard.

      1. Bleu

        Re: Not bad

        It's not so much a paradigm, but intended to allow more readability in the many languages that allow it or aren't based on models that exclude it.

        That, plus a little comment to explain what the loop variable is to count and why, a declaration leaves a neater space and is a better place to describe the variable in a comment, must be so out-of-fashion now.

        Can't go trying to write readable programs, can we?

        1. Brangdon

          Re: Not bad

          If the loop variable is declared at the point it is used, and has a sensible name, it probably doesn't need a comment.

  7. Evil Auditor Silver badge

    Lee, that's great! If you ever get bored of programming, I'd recommend starting with "Democracy for Dummies".

    1. Alfred

      And what would be the advantage of Singapore becoming a less restrictive society? Democracy isn't some kind of magical higher state that all humanity should strive for.

      1. DavCrav

        "And what would be the advantage of Singapore becoming a less restrictive society?"

        If you are one of the people currently being "restricted" then I guess there is an advantage.

      2. Anonymous Coward
        Anonymous Coward

        Yes, Democracy is what all humanity who doesn't have it at the moment should strive for.

        "Democracy isn't some kind of magical higher state that all humanity should strive for."

        Oh but it is, and if you don't see it, you're not smart (enough). Senior Wrangler or not.

        If you want me to be patronising, here is why:

        - It allows the voices of minorities to be heard.

        - It promotes dialogue over punishment, violence, anger and grief.

        - As a side result, it promotes harmony and respect over confrontation (we all know attempts to muffle discontent only results in more confrontation and more unpleantry brewing underneath).

        - It sets an example at the highest level as to how a proper person in a proper civil society should behave.

        No other political systems are able to do so, any type of government system that promotes and accepts censorship will eventually fail, it may take years, or generations, but it will, simply because civilization and people are like a maze of pipes joining into a grand stream.

        If you attempt to shut one pipe, you'll just cause blockage and eventually the pipes bursts, and whatever caused you to block that pipe may just flow into another.

        Also democracies tends to be decentrailized systems, and any programmer (who has experience in big data, cloud) will be able to tell you that decentralized systems are the way to go. In fact if you look at the software world, the biggest, most scalable, most efficient systems are decentralized.

        It isn't _the_ ideal political system, but it is none-the-less a step in the right direction _for all humanity_.

        It's unfortunate that you can't do much reasoning to a bunch of people who're basically birds in a cage that are well provided, they think the world is great and their master is their god. I don't expect anyone from such societies to be able to see the problems their systems have.

        Frankly, anyone can program, I'm pretty sure now-a-days most 5 year old with a father in IT/Tech industry can, so this news about a PM in Singapore being able to program a simple program in C++ that only has a couple of hundred lines of codes is frankly not newsworthy, not worth any admiration what-so-ever.

        And I think some of the comments above mentioned this already. The worst thing is when you have a person who believes he knows more than he _actually_ knows. I can only hope this guy isn't one of them. Not that I care, I would never set foot in Singapore as long as it has a set of draconian laws on free speech.

  8. Torben Mogensen

    Haskell

    He mentioned wanting to learn Haskell. Here is a link to a small Haskell program for solving Sudoku: http://web.math.unifi.it/users/maggesi/haskell_sudoku_solver.html

    1. Paul Kinsler

      Re: Haskell

      And Haskell can (might) help you learn physics :-)

      http://arxiv.org/abs/1412.4880

    2. phil dude
      Thumb Up

      Re: Haskell

      compact! Perhaps I need to read it in Emacs....

      P.

  9. Anonymous Coward
    Anonymous Coward

    David Cameron's would achieve this....

    ...by forcing the sick, elderly and infirm to calculate them by hand for their benefits.

    The contract to run this scheme would cost millions of tax payers cash funnelled into Tory party donors hands.

    1. tony2heads

      Re: David Cameron's would achieve this....

      I would trust the sick, elderly and infirm to be able to calculate them more than most politicians.

  10. Alfred

    Senior Wrangler

    Not just a funny academic title in a Pratchett novel. It's also a deeply impressive achievement; 李显龙 is ferociously smart.

    1. Anonymous Coward
      Anonymous Coward

      Re: Senior Wrangler

      Absolutely. For a good indication of how impressive this is, look at who has finished *second* in past contests. According Wikipedia, James Clerk Maxwell, J. J. Thomson and Lord Kelvin - to name just three.

      1. DavCrav

        Re: Senior Wrangler

        "Absolutely. For a good indication of how impressive this is, look at who has finished *second* in past contests. According Wikipedia, James Clerk Maxwell, J. J. Thomson and Lord Kelvin - to name just three."

        As any Senior Wrangler would tell you, that isn't much evidence that he is clever, since each year you are competing against different people.

        However, Senior Wranglers are generally pretty good.

  11. Tromos

    Logic - Problem solving - Politics

    Choose the odd one out.

    1. JetSetJim

      Re: Logic - Problem solving - Politics

      I thought that was a variant on the old "speed, size, cost - pick two" engineering saying.

      Logic & problem solving => proper solution, may not be politically expedient

      Logic & politics => a solution, may not be what solves the problem though

      Problem solving & politics => a solution, may not be logical

  12. crayon

    "Frankly, anyone can program, I'm pretty sure now-a-days most 5 year old with a father in IT/Tech industry can, so this news about a PM in Singapore being able to program a simple program in C++ that only has a couple of hundred lines of codes is frankly not newsworthy, not worth any admiration what-so-ever."

    The news factor is not that some random Tom/Dick/Harry can program, but rather a world leader can program. Eg if it were known that you always go to sleep wearing soiled underpants on your head the newsworthy factor would be zero, if a world leader was known to do the same the newsworthy factor would be non-zero.

    "Yes, Democracy is what all humanity who doesn't have it at the moment should strive for. ... I would never set foot in Singapore as long as it has a set of draconian laws on free speech."

    Democracy is not a panacea that will solve all humanity's problems. There's also the problem of what you mean by "democracy", for me a basic requirement would be universal suffrage - based on the modern definition, which is, that all adult citizens are allowed to vote. By this measure the USA did not become a democracy until the 1960s, but every time India has a general election, US pundits like to boast about the US being the oldest democracy and patronise about India being the largest democracy. The latter maybe true but the former is dubious.

    What benefits has democracy brought India? For the majority of people (ie the poor) the only tangible benefit of having elections is that they will receive bribes of basic foodstuffs from politicians wanting to buy their votes (and does it still count as democracy if votes can be bought so freely and cheaply?). Sure they have freer speech than in Singapore, but by itself it will not put food on the table. Food and water security, healthcare, literacy, education, discrimination, corruption - these are all more pressing issues for people in poverty than the notion of democracy. When people in Singapore want more freedom of speech they will know where to "ask", politely or otherwise. There's no need for well meaning or patronising foreigners to say what Singapore should or should not have.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like