Slashdot Mirror


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.'

12 of 230 comments (clear)

  1. That's C code by Anonymous Coward · · Score: 1, Informative

    Not C++.

    1. Re:That's C code by fisted · · Score: 2, Informative

      void Succeed()

      That's actually more C++'ish, a C programmer would put it as

      void Succeed(void)

      Which means in C what the former means in C++.
      </nitpick>

      Apart from that, yeah. It's pretty much C. Almost C89, even, were it not for the C++ style comments and two instances of mixed declarations and code.

  2. It may have a .cpp extension but it's all C code by Anonymous Coward · · Score: 2, Informative

    I guess C++ just sounds higher tech.

  3. Put in context by Anonymous Coward · · Score: 5, Informative

    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.

    1. Re: Put in context by Anonymous Coward · · Score: 5, Informative

      Wiki link to those who aren't across Cambridge lingo

      http://en.m.wikipedia.org/wiki/Senior_Wrangler_%28University_of_Cambridge%29

      The Senior Wrangler is the top mathematics undergraduate at Cambridge University in England, a position once regarded as "the greatest intellectual achievement attainable in Britain."

    2. Re: Put in context by Anonymous Coward · · Score: 2, Informative

      The Senior Wrangler is the top mathematics undergraduate at Cambridge University in England, a position once regarded as "the greatest intellectual achievement attainable in Britain."

      In other news wiping an adult mans arse was once considered the greatest political achievement attainable not by birth in Britain.

  4. Re:It may have a .cpp extension but it's all C cod by AuMatar · · Score: 4, Informative

    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?
  5. The actual code by Anonymous Coward · · Score: 5, Informative

    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...

  6. Well... by EmeraldBot · · Score: 3, Informative

    While not utilizing any of c++'s features, it is still valid c++. I think he might call it this because he may usually program in c++, but maybe just for this one project he did it in c, and since it's still legal c++ he finds it easier to just label it as c++. I actually quite like it - could use a bit more commenting, but overall very clean and readable. Should compile with a decent c or c++compiler...

    --
    "Set a man a fire, he'll be warm for the rest of the night. Set a man afire, he'll be warm for the rest of his life."
  7. Re:From his Facebook post on his Sudoku solver by UnknownSoldier · · Score: 2, Informative

    That's common knowledge.

    Bit Twiddling Hacks

  8. Re:Lead By Example?! by antiperimetaparalogo · · Score: 4, Informative

    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!
  9. Re: Technically C++ by Sique · · Score: 4, Informative

    I guess, Angela Merkel knows. At least she wrote a program to simulate electron movements for her PhD thesis.

    --
    .sig: Sique *sigh*