Hacker News new | past | comments | ask | show | jobs | submit login
[dupe] PM of Singapore Shares His C++ Sudoku Solver Source Code (drive.google.com)
209 points by doppp on May 4, 2015 | hide | past | favorite | 150 comments




I like this one a lot:

    Entry[Square] = BLANK; // Could be moved out of the loop
Maybe I'm reading too much into it, but this type of thinking makes me smile. The guilty perfectionism, "this can be improved."

Were I from Singapore, I'd be happy to see it in the person in charge of my country.


Please remember that Signapore has no free speech. I am kind of angry we're cirlclejerking about a PM whose a criminal according to my view http://en.wikipedia.org/wiki/Human_rights_in_Singapore

Can we please just ignore this dictator and be amazed about code of other people instead?

It just feels wrong.... I think freedom of speech is a very very important part of the hacker community. I think no sane person would want this person in charge of his country. Coder or not.


As a foreigner living for 2 years in Singapore and coming from an unstable country I can say that Singaporeans have more freedom than any other citizens in the world. Like Mr. Calvin Cheng says:

"I tell you what freedom is.

Freedom is being able to walk on the streets unmolested in the wee hours in the morning, to be able to leave one's door open and not fear that one would be burgled. Freedom is the woman who can ride buses and trains alone; freedom is not having to avoid certain subway stations after night falls. Freedom is knowing our children can go to school without fear of drugs, or being mowed down by some insane person with a gun. Freedom is knowing that we are not bound by our class, our race, our religion, and we can excel for the individuals that we are - the freedom to accomplish. Freedom is living in one of the least corrupt societies in the world, knowing that our ability to get things done is not going to be limited by our ability to pay someone. Freedom is fresh air and clean streets, because nothing is more inimical to our liberty of movement than being trapped at home because of suffocating smog.

These are the freedoms that Singaporeans have, freedoms that were built on the vision and hard work of Mr Lee, our first Prime Minister. And we have all of these, these liberties, while also being one of the richest countries in the world."

The whole article is great http://www.straitstimes.com/news/singapore/more-singapore-st...


This definition conflates freedom with security, while describing normal life in a big portion of a civilized world, where all these things are achieved with less limitation in other spheres of life. Especially regarding sex and drugs.

Singapore isn't a free country. It's very efficient, rich and safe, yes.


> Freedom is knowing that we are not bound by our class, our race, our religion,

Just as long as you're of Chinese ancestry, of course.


I am sick of seeing "free speech" treated almost as religious dogma, as if it is axiomatically good. It's not - it's just a theory that unrestricted free speech will lead to a better society. Frankly, I don't think that is anywhere near proven yet (nor do I think even democracy has been "proven" to work long-term).

I actually like that there's lots of little experiments going on, trying any number of positions on all the little dials of society. Time will tell which ones work.


Its not just free speech (which ironically takes care of other issues as it allows proper multi-party politics and being able to 'talk to power' without reprisal).

Its also LEO abuse because their system allows unlimited detention without charge. Homosexual rights are non-existant: Prime Minster Lee Hsien Loong has spoken dismissively of the challenges to article 377A: “Why is that law on the books? Because it’s always been there and I just think we leave it. I think that’s the way Singapore will be for a long time.”

If that wasn't bad enough:

Singapore’s Media Development Authority issued a regulation effective on June 1 that banned major news websites available in Singapore from “advocating homosexuality or lesbianism.”

All Foreign domestic workers are excluded from the Employment Act, which provides employment protections.

Its easy to sit here on your expensive computer and fast internet connection in a Western country and pretend living under a regime like this is wonderful. You're not a gay man being jailed for loving your partner or a poor Philipino being beaten by his employer because he cant work 18 hour shifts everyday. Apparently, curtailing speech didn't fix these issues, so why are you advocating for it?

>I actually like that there's lots of little experiments going on,

We've gone down this path a million times. Its not surprising that it brings the same results as before.


Oh lordy. I'm currently in the country living under this "regime" and am quite amused by your description. I can honestly tell you that the government doesn't go round busting into people's houses trying to catch gay men loving their partners. WRT the domestic workers, (btw, you got the gender wrong- they tend to be females) and there are severe punishments for abusing them. I've also noted occasional reports in the news about employers being jailed and such.


I've heard this so many times from people that live in a place where one of this "little experiments" is not happening.

It is easy to be an anarchist or communist when you dont have to live in such a place.


I've lived and worked extensively in singapore, thailand and china, all with speech controls. They all have their pros and cons and I'd be hard pressed to categorically state they're better or worse than my home country of Australia.

> you dont have to live in such a place

True, and neither do they. Singapore's a first world country; its citizens can settle elsewhere with relative ease. And yet they don't. I wonder why?

And just to turn your rhetorical device against you, what I've heard "so many times" is these self-righteous rants by people who have never even visited the place they're criticising, but they're oh so sure they're right anyway. And for what it's worth, the USA is an experiment too, and from an outsider's perspective I'm not sure it's working out too well.


> And just to turn your rhetorical device against you, what I've heard "so many times" is these self-righteous rants by people who have never even visited the place they're criticising, but they're oh so sure they're right anyway. And for what it's worth, the USA is an experiment too, and from an outsider's perspective I'm not sure it's working out too well.

Just as an FYI, not "rethoric" from my side. I was born and raised in a country that went through a hell hole of super inflation and constant bombs going off from a "marxist" terrorist group known as the Shining Path. The "president" that "fixed" this situation was really a dictator that did not pay attention to human rights or democratic due process. The terrorist group got destroyed and "order" was brought into place at the expense of free speech and true democracy. Oh yeah, and he put a bomb in my dad's car because he disagreed with his political views. Those were the two first decades of my life.

So I kind of know what I am talking about.

If Australia was truly going through free-speech "problems" - I am sure you would not be so easy to refer to these "experiments"


I'm sorry to hear about your experiences, I mean that. But I don't see how that has much to do with what we're talking about.

I wish you'd step back from your personal trauma and look at the big picture. You say this "terrorist" group caused the rise of a dictator and the loss of free speech and democracy. Why didn't free speech and democracy stop such instability in the first place, if they're such a panacea like you seem to think? Because that's exactly what I'm talking about - the ingredients of a stable, wealthy, secure and fulfilling society.

Of course, the irony is that that would have never happened in Singapore.


You dont think it is presumptious of you to think you can somehow dissect a situation in an entire region (South America) without clearly any historical knowledge that can give you meaningful context? I say this because your question "Why didnt free speech and democracy stop such instability in the first place?" show a clear misunderstanding/lack of knowledge and tremendous oversimplification of Cold War era politics, neo-colonialism, caudillism, Spanish feudalism and decentralisation of power. Breaking it down to a simple explanation of "is free speech and democracy good and if such why didnt it help here?" is clearly silly at best.


Your comment was also a ridiculous over-simplification. My reply was a bit facetious, which was probably silly of me. But whatever. We both fail at arguing; I have not influenced you nor have you influenced me.

Anyway, it appears that I'm now treading on people's toes so that's enough from me.


I succeeded at pointing out how haughty, supercilious and disconnected your comments about democratic experiments... Even though you were quick to downvote my replies.

Enough for me, too.


This account doesn't have enough karma to downvote anyone :-P


Then you did succeed at convincing somebody out there! :)


Except people in Singapore stated they like it there.

And I considered moving to Singapore a couple times, if I get ever invited for a job there, I would promptly accept.

I don't agree with lots of their laws, but I must recognize that it works. (Singapore is clean, safe, has good business freedom, the government does not tolerate racism and religious hate, and the city has a very interesting functional design).


Sure the world you would step into when you went to Singapore would be great and fine. However if you consider the fact that Singapore has the highest gini coefficient (measures wealth inequality) [0] then the inability to speak freely might be pretty awful for the peoples at the bottom. It's easy to gloss over the weakest links in our societies (we sure do it well here in America, and probably almost everywhere) but you really have to remember that your Singapore isn't most people from Singapores Singapore and therefore it only seems fair to include a postfix: I don't agree with many of Singapore's laws but it works for me.

[0] - http://thehearttruths.com/2013/02/21/singapore-has-the-highe...


> Except people in Singapore stated they like it there.

In a country where you are not allowed to openly criticize the ruling power, how can you even measure what people of Singapore really like?


Even in countries with heavy censorship, you can tell if large groups are unhappy, they might state they are happy with their mouths, but body language, and general behaviour will show otherwise.

Also, problematic countries also frequently have some dissenters, and people that managed to flee and speak against it while outside it.

Singapore don't forbid you to leave, and all people I ever talked that went to Singapore, or lived in Singapore but where outside Singapore, mostly only had praise for the country.


Looking at Grandparent's link, they also execute drug traffickers, which is kind of excessive, IMO.

And "better society" isn't the only reason to believe in "free speech". Another reason is the moral principle that one should not be imprisoned for a political opinion.


Not only do they execute drug traffickers, they have a very loose definition of what "trafficking" means.

If you are in possession of at least 500g of marijuana, you are BY DEFINITION considered to be trafficking it, regardless of intent. This has a mandatory death sentence. And here's the best part: the definition of possession is:

    any person who is proved to have had in his possession or custody or under his control —
        (a) anything containing a controlled drug;
        (b) the keys of anything containing a controlled drug;
        (c) the keys of any place or premises or any part thereof in which a controlled drug is found; or
        (d) a document of title relating to a controlled drug or any other document intended for the delivery of a controlled drug,
    shall, until the contrary is proved, be presumed to have had that drug in his possession.
So simply having the keys to an apartment that contains 500g of weed is enough to get you executed in Singapore, theoretically.

(Source: http://en.wikipedia.org/wiki/Capital_punishment_in_Singapore...)


It's a good indirect way to get rid of someone. Just put drugs on their apartment and call the cops.


I am from Brazil, and although I am against the drug war, I do believe that the sort of drug traffickers they execute, are not really a problem in being executed.

For example Indonesia recently executed two brazillians, and although our president keeps complaining, cut relations with Indonesia, and whatnot, the population is HAPPY they executed those two scumbags, we just wish more scumbags would make the same mistake and get executed too.

You might wonder, why is that? It is because in Brazil we have a full blown civil war going because of drug traffickers, the drug traffickers here frequently have very heavy weapons (rocket launchers, grenade launchers, mortars, anti-material fixed machineguns and rifles, they even tried to buy some small missiles once in the international black market), and are perfectly willing to use it (so our government must hand our cops military gear, literally, to handle, war-style combat, with armoured vehicles, helicopters and infantary trading heavy fire is not uncommon, and in some cities we have more absolute deaths by gunfire than the whole Iraq summed per day).


But you need free speech to conceive of, prepare for, and then execute an experiment. If you limit speech, then you limit the kinds of experiments you can even talk about, let alone run.


It's funny, I have next to no knowledge on the current state of Singapore or it's politics. I have no idea what this man's political views are, or how well he has been leading. But seeing this code (and little bit of personality left in comments like the grandparent post) does make me like the PM more, as a person and a leader. It's not really rational, but it's the truth.

I guess I finally understand the whole "I want a president I could play sports / grab a beer / whatever with" sentiment.


>I guess I finally understand the whole "I want a president I could play sports / grab a beer / whatever with" sentiment.

This always seemed like an excuse by a defeated people. They know their person in charge is a nightmare and limits their ability to be free actors, so they just rationalize it away in a Stockholm Syndrom-like way. "Hey he's a good guy, you'd like him if you met him."

I see this a lot with Russians who know full well Putin is dictator for life and they essentially have no rights or recourse against his administration, but play up a positive bullshit spin like "standing up to NATO/Nazi killers in Ukraine" or "bringing us back our Soviet glory." Its pathetic and on some level even the die-hards know it.


Yes, let's ignore the programming aspect of this story so we can focus on the political aspect instead. That's what HN is for.


The programming aspect of this story is barely relevant here. A basic sudoku solver by itself isn't HN material. The reason why this story is interesting is because it involves a high ranking politician.


It seems like a nerd version of Putin riding a bear or whatever. "Look, I'm one of the people."


This is code written by a criminal. That is relevant. Context matters. It has nothing to do with politics.


Dictator? I don't think you know what that word means. Maybe you should come visit and see exactly how off the mark your comments are.


Singapore is a single-party state with almost no regards to human rights. Political dissidents are routinely either jailed and tortured or fined and driven out of the country.


>routinely either jailed and tortured...

I'm not sure there is record of anyone being tortured, let alone it being routine?

One of my Singapore female friends pointed out you have a far lower chance of being raped or mugged if you walk around in Singapore than in most other countries and she considered that a more important than the ability to insult the government without them trying to sue you.


> One of my Singapore female friends pointed out you have a far lower chance of being raped or mugged if you walk around in Singapore than in most other countries and she considered that a more important than the ability to insult the government without them trying to sue you.

But when you put it this way, it sounds like there's a link between these two properties. I don't see how restricting free speech improves the safety of women.


I could have put that in a less muddled way. I think I was trying to get at that if you want to get on with life without being beaten, killed, imprisoned, tortured of raped you have a better chance of that in Singapore than many other countries. Indeed I imagine all of the above are statistically more likely in the US for example.

I don't think restricting freedom of speech helped directly but both things are to some extent the result of a rather authoritarian government. Singapore isn't perfect but probably has a better quality of life than many of its neighbours.


That may be true. You could make that kind of comparison about a lot of the human rights we enjoy vs. the benefits of their absence. In this case, there doesn't seem to be any obvious connection. How does silencing political speech prevent rape and mugging?


GP is likely referring to the on-going, completely sanctioned and culturally ingrained practice of corporal punishment for what would otherwise be minor offenses in the Western world. While likely not thought of "torture" in the minds of Singaporeans, the thought of corporal punishment is abhorrent to many of the 20-30 somethings in Western urban environments.

https://en.wikipedia.org/wiki/Caning_in_Singapore

https://en.wikipedia.org/wiki/Vandalism_Act_(Singapore)


Are you trying to say it isn't abhorrent to people who are not in their 20s or living in urban areas? I don't think that's an accurate statement.


No, sorry, that statement wasn't meant to be exclusionary. People of all living situations and ages could definitely find it abhorrent. Just expressing my opinion that that specific demographic would likely slant extremely heavily towards calling it inhumane, if not outright torture. People in older generations are sometimes closer to having been the recipients of corporal punishment themsleves, whether in school or at home, and my vague inclination suggests that these practices might have continued longer in rural areas than in urban areas. In that way, they might not see it as inhumane, but younger generations might.


There seems to be a very loose definition of dictatorship going on here.

`Dictator`

a ruler with total power over a country, typically one who has obtained power by force.

Singapore isn't a single-party state. There are other political parties that take part in the elections. Singapore's government is made up of members from mostly one party because the people voted them in. Let me repeat the last part: the citizens of Singapore voted the party in on their own accord. That's not a dictatorship. No one pointed a gun at my head and told me to vote for the incumbent party.

And as for your point about political dissidents, while that is true and is an important part of the history, it doesn't really happen now. What normally happens is that someone says something stupid that borders on libel and defamation and he gets sued. Is is heavy handed? Probably. Were they breaking the law? Yes. Is this a sign of dictatorship? On it's own, no.

There is heavy censorship, there is the death penalty, I believe Singapore still sell land mines, homosexuality is against the law. There are many flaws about Singapore but to call the state a dictatorship is putting the wrong label on the country.

When you say `Dictatorship`, I think North Korea, Iran. There is no way in the world Singapore even comes close to being a North Korea or an Iran.


Also one of the few countries in the world to use corporal punishment, such as canings, in response to crimes.


Singapore is a different deal than most countries in the world. Perhaps free speech and civil liberties are not as strong there, but that trade-off gains them freedom from other things. Singaporeans are largely free from lots of types of crime that effectively plague many other first-world countries.

I think it would be nice if there were more countries that presented different types of trade-offs, and then some mechanism for people to decide what type of country they want to live in.


Yes I think it's interesting to realize democracy isn't the golden bullet (it isn't) but I think freedom of speech and freedom of assembly are two very important rights that should be protected in your constitution even if you're not 'democratic'.

The problem is that the people have no way to overthrow or even audit their government. That's all nice and roses if the government is acting in good faith of its citizens (which people here claim is happening in singapore). But what if the next person is just totally insane? And abuses all his powers? You have no way to protect yourself from an abusive government. Which is very concerning.

Maybe I'm too extreme in this? I don't know. But at least I can decide right?


I'm not sure that Singapore is any more at risk of an abusive government than other countries. Freedom of speech and assembly might let you protest against an abusive government, but if the government isn't interested in obeying laws, those freedoms can just be ignored. It's not as though governments always obey their own laws.


I notice this kind of behavior a lot. People praising someone for silly little things (even when the person does not deserve to be praised in general). One that comes to mind that gets this kind of response a lot would be the current pope.


I have to say as an atheist the current pope seems a huge improvement on the previous models.


Controls on speech were necessary for Singapore to move from a third world country to a first world one in just 30 years


I don't think that this comment was meant to signal approval of the strict/oppressive speech and press rights in Singapore, but it unfortunately reads as such. If I am misinterpreting your comment, how do you reconcile the apparent "if and only if" relationship you're positing, with countries like South Africa, Czech Republic, Slovakia, etc., that while not strictly third world, have seen increasing economic successes come in conjunction with increasingly free policies over the past 30 years? Superficially, Singapore appears to be the exception and not the rule: Myanmar, Indonesia, Philippines all have seen greater growth as liberalization progresses, as well.


It's an old argument. A statist (a polite word for fascist) regime can quickly correct obvious inefficiencies leading to a quick and easy boost in productivity. Hayek argues that the jolt is temporary and, in so far that nothing creative seems to come out from Singapore, he seems be at least partially correct.

The question is, however, if this is a regime we'd like to live in. A regime where dissent is closely regulated and suppressed (including through canning). A friend's father, formerly an editor of the WSJ, is banned from Singapore for writing an article critical of the boss.

I don't think it's a coincidence that Silicon Valley is in CA and has attracted millions throughout the world, to program. People take risks and failure is a badge of honor - not a stain on your family's honor.

Meanwhile Singapore has someone who was, according to his ex-adviser, a great mathematician/programer. But then he joined the consultant/political class.


Explain please? I don't know much of the history of that area.


Two reasons are generally put forward.

The argument put forward by Lee Kuan Yew (RIP) for exiling communists was that Maoist China was aggressively attempting to expand into the region. For example, see the Hong Kong bombing campaign of 1967 [1]. According to, amongst others, "The Singapore Story" [2], he was initially contacted by the Communists to represent them as a "moderate" leftist. His manoeuvering to win the 1959 election (scaring many businesses away to KL, thinking communism had won) and kick them out relatively bloodlessly thereafter has become legendary in Singapore, and is I think unparalleled anywhere else in the world. Part of winning included controlling the press and winning the PR battle. Whether it was justified depends on your stance on communism (and therefore if you consider the country to have been at war, suspending individual rights).

The second is that the island is racially very diverse, with a majority Chinese when both neighbours - who were also aggressive at the time - were of a different race and religion. Independence came a couple years too early due to Malaysian worries that LKY was not cooperating with their policies (Singapore was openly advocating racial equality amongst other things, against the pro-Malay discriminative policies from KL). Still in the 1960s, there was an explosion of anti-Chinese minority riots in neighbouring countries which involved some lynchings, and some Chinese had the idea of doing the same to Malays in Singapore (e.g. [3]). LKY's response was prompt: he pushed for the Chinese rioters to be made an example of. Restrictions on hate speech grew from a need to quell these tensions. There were no more race riots until the recent incident where a drunk construction worker was run over by a bus and the mob got angry.

It's important to view his actions not as if you lived in the prosperous United States, surrounded by a large ocean and coming out victorious from the largest war known to mankind but as the leader of a tiny island surrounded by enemies big and small, open and insidious. I ask his critics what they would have done differently; I personally agree with those who consider LKY one of the greatest politicians that ever lived, and I admire the Singaporeans for electing him year after year.

[1] http://en.wikipedia.org/wiki/Hong_Kong_1967_Leftist_riots: "Bomb disposal experts from the police and the British military defused as many as 8,000 home-made bombs. Statistics showed that one in every eight bombs was genuine."

[2] http://www.amazon.com/The-Singapore-Story-Memoirs-Kuan/dp/01... - a worthy read if you love history, but if you are short on time, read "From Third World to First" instead.

[3] http://en.wikipedia.org/wiki/1964_race_riots_in_Singapore


Interesting theory. Do you have any evidence whatsoever to support that assertion?


It worked for South Korea and Taiwan. They were both ruled by strongmen on the fence between dictatorship and autoritarian democracy. Park Chung-hee industrialized S Korea in 20 years by ruling with a rubber-stamp parliament and a disregard for human rights. The country emerged stronger and gave way to a true democracy with 20 years of his death.


The trouble is that that doesn't prove that similar increases in prosperity could not have occurred without widespread human rights abuses.


   USA is built on human Rights abuses first of native Americans then African Americans today you might talk about how free speech got USa where it is. But that is not true is it if you look at your history same is for most of the western world.
   Today US consumerism is built on human rights abuses of people in other countries but free speech whatever. Forget people of other countries many of your local goverments and corporations are being run on human rights abuses of people of color and Hispanics. Either by incarceration or being used almost like slave labor in your large farms.


"The people responsible for suppressing speech said so."


And nobody dissented!


Why?


Hopefully OP will elaborate on his thinking, but I'd hazard the thoughts were something along the lines of "sectarian violence in Iraq needs to be controlled to let it become a modern country."

I.e. democracy is a fairly terrible vehicle for progressive change, as by definition you're going to be fighting against inherent conservativism (both terms used with social rather than political definitions) in a majority of your population. I know nothing on the history of Singapore, but /hazardGuess.

(Whether or not you agree with that perspective is a valid question, ofc)


The problem with Iraq wasn't "democracy" but colonialism (which created a faux country out of nowhere with problematic arbitrary and non-historical borders) and invasion.


Iraq has a lot of problems. Historical and modern.

And you never really commented on the original point: (given Iraq's, or any other similar state's, current state and status) is democracy and free speech the quickest path towards a more modern state?


I don't think the citizens of a state are pawns or little children, so that we can ask "what restrictions on them would be the quickest path towards a more modern state".

That's the "You can't handle the truth" approach, which I abhor.

Now, if (for the purposes of discussion) say that we value having a "modern state" (which is vague in itself) over freedom, democracy, free expression, etc, then, OK, what you write might be a quicker path to it. And Iraq, Libya, etc was indeed more stable under their previous regimes than they are now (of course for those, foreign interests have a lot to gain if they are unstable, and will "help" them be unstable by playing all sides against each other).

It also raises the question what kind of "modern state" would that be, that was created with restrictions in democracy and free speech?

Historically people have shown (expressed but also proved with their actions) that they can value freedom (as they see it) over convenience and even over their lives (from Spartacus to numerous examples to many to mention). If for a state the kind of people want to be established there needs to be tension and people fighting over the outcome they want, then so be it (even if the final positive outcome is not guaranteed).

Just like France had to have the bloody revolution to become a modern state, the US had to have a revolution and a civil war, etc.


Nor do I, but I allow for the possibility of the ends justifying the means still being a moral path in some circumstances. I also purposely tried to leave out "stable" as a goal adjective, as I agree that's an entirely too amorphous term.

I think Turkey is an interesting, if heavily cult-of-personality, example.

In essence, the US Supreme Court is a very real check on democracy and free speech. The former in that it can override democratic decisions, and the latter in that it has decided in several judgements that the right to free speech is not absolute (that it has not done so more frequently is kind of immaterial to the ideals of the state).

I would argue as a that historically people have show that they value personal gain more than either freedom or convenience, particularly in exactly the kind of government-today-gone-tomorrow states we're talking about.

As soon as you involve people with guns, then the person with the biggest gun starts having a better argument. Which is how you get central African transitions as opposed to South Africa.

A new state is only one of the potential outcomes of revolution. Endemic violence is another (Somalia, Congo, Afghanistan, Iraq).


No country in the world has real free speech, whereby free speech means you can say whatever you want without going to jail (or to guantanamo).


You wouldn't want to be accused of censoring code, would you?


American living in Singapore. For me, it's all about economic stability and employment opportunities, the two things I found lacking in US. I graduated in late 2000s in US and it was a really hard time for me. It was especially disappointing later to find that no one was even prosecuted.

"Well, at least our country has freedom of speech, brah!"

Yeah, no. I'd rather live in a country that provides a good living for its citizens and doesn't squander its wealth war mongering around the world for the sake of protecting some vague notions of "freedoms".


I feel this. I just bounced from the USA for east asia permanently and couldn't be happier. No guns, no crime, peaceful people, no fear of burglary/mugging/fraud, better food/diet, lower taxes. I am still trying to get used to leaving my helmet sitting in plain view on my scooter, unlocked, for hours at a time.

My life now is the antithesis of my life in San Francisco (worst city I have ever lived in overall), and I couldn't be happier.


You would be happy to have a person who mixes tabs and spaces as your PM? ... mixes tabs and spaces. Argh.


That's a pretty common style in C++. If he were a Ruby programmer and did that, then I'd be less happy.


That's pretty common style in Ruby. If he were a Python programmer and did that, then I'd be super unhappy.


Python doesn't even allow tabs by default, does it?


You can use tabs and spaces, you can even use both without any problem. However, your indentation has to be coherent along the whole file. So you can use as your indentation pattern "4 spaces", "one tab", "2 spaces", "one tab + 2 spaces", but you can never change your pattern in the middle of the file, once you have chosen one pattern, you have to keep this one till the end of the file or it'll throw an indentation error.

But in reality, you should indeed stick with the "4 spaces" PEP8 compliant style.


once you have chosen one pattern, you have to keep this one till the end of the file or it'll throw an indentation error.

Only if the resulting indentation is an actual error. It's quite possible that the parser's interpretation of resulting indentation is a valid program with different semantics than you intended.


It does, and it doesn't warn you if you have both, it just breaks your program.


Python 2 does, Python 3 does not:

> TabError: inconsistent use of tabs and spaces in indentation

Note for pedant: Yes, you can mix tabs and spaces in Python3, but only if you do it absolutely consistently for the block and all sub-block.


Not really. I wouldn't say it's more common in C++ than in anything else I've used. Usually the people who do it mix tabs/spaces in every language.


Ok I believe the phrasing of this comment makes its point a little unclear. Some people are saying how this demonstration doesn't guarantee that the president is a good one. This is true, but I believe the original comment here is merely saying that it is better to have a president WITH this characteristic than without.


>This is true, but I believe the original comment here is merely saying that it is better to have a president WITH this characteristic than without.

Or maybe there's no correlation at all? In the sense that NO, it's not better to have a presidnet with this characteristic thna without, it's equally likely that both the president with and without this can be a bad politician.


I'd be happy to see it in the person in charge of my country.

Would you be equally happy to see Herman Cain as President of the US? He also has Masters in CS and spent the early parts of his career as a programmer.


I think you're focusing too much on the particular detail. The idea of the comment as I understand it is that the code shows attention to detail which is a desirable trait in a leader.


Sure, but I know lots of people with great attention to detail that I wouldn't want anywhere near running my (or any other) country.


That was the popular conclusion about Jimmy Carter, nuclear engineer.


That's maybe because he's the only US President in the last 110 years that didn't start a war. It's sad that he is frequently criticised as being weak. (most likely because of that)


What war did Obama start exactly? If you're referring to the continuation of America's involvement in Afghanistan, let's not forget who was the president who first got America in there and provided training and financial support to the forerunners of the Taliban. That's right, Jimmy Carter.


Indisputably Lybia. One might also consider several regime changes and interventions in the Middle East and Europe (Ukraine) as acts of war.


While I find the code to be interesting, I wouldn't exactly claim to want this person as my PM.

Great, he used to program and displayed a handful of positive character qualities in doing so. A lot more than that is required to be an effective leader of a country.


Certainly a lot more is required. But this demonstrates that he's not some high-level politician that's completely out of touch with today's reality. It shows he's capable of logical thought. Two qualities I'd prioritize over all others in my leading politicians.


"But this demonstrates that he's not some high-level politician that's completely out of touch with today's reality"

It demonstrates he can write a sudoku solver in C++, I don't see how this has anything to do with being in touch with reality.


Today's reality that Software Code Is Everywhere. There are other aspects of reality that are most assuredly not addressed by the PM's programming prowess.


It shows he's capable of logical thought

He is a senior wrangler.


I think the distinction the grandparent made was they would be happy to see the trait in the leader of the country, not that seeing the trait makes a good leader.


I've put it on GitHub in case this is ever removed. :)

https://github.com/Doppp/LHL-Sudoku-Solver


Code without a license on it is not public domain. In this instance, he probably won't care, but it's a bad habit to get into.


Yeap, great idea :)


Clinton could play the Saxophone, after that I am struggling to think of any politicians able to demonstrate a useful skill.

Programming might not be that hard to pick up if you had done it before, couldn't this code have been written on a 25 year old computer to compile with a Borland era compiler?

Because the wider population don't understand programming and see it as magic, I fully expect his popularity to do well, he is practically a hacker in their eyes, able to conjure up magic and demonstrate skill.


Vladimir Putin is a bona fide Judo expert. I guess it's debatable how 'useful' that is - just like playing the sax.

"Because the wider population don't understand programming and see it as magic, I fully expect his popularity to do well, he is practically a hacker in their eyes, able to conjure up magic and demonstrate skill."

The circle jerking in this thread rubs me the wrong way - "this guy must be awesome, he can pass a 1st year 'introduction to computer programming' class!". Must be the cognitive dissonance - there are people still saying Hans Reiser was surely framed, because how could a programmer be anything but God's gift to mankind?


Margeret Thatcher was a chemist. She's variously credited with inventing "raspberry ripple" icecream, or "Mr Whippy" soft-serve style icecream. (The last one is definitely not true, it was invented a long time before she started working).


Angela Merkel has a PhD in physical chemistry.


>> "Because the wider population don't understand programming and see it as magic, I fully expect his popularity to do well, he is practically a hacker in their eyes, able to conjure up magic and demonstrate skill."

The general public don't think of you as some sort of magic hacker because you code for a living, sorry.


... he didn't imply they did


Manmohan Singh (former PM of India) was an economist par excellence. As the finance minister, he was responsible for the liberalization of the Indian economy and arguably responsible for the economic boom in the country today. But his tenure as a Prime Minister is largely remembered for his missteps and his general nonchalance to everything that happened around him. His legacy was tarnished and now he is just remembered as a puppet PM.

So yeah, extra curricular skills and fancy degrees and academic credentials may not translate into a good leader of the country.


demonstrate a useful skill

Speaking in public (especially to very large crowds) and not turning into a nervous wreck is not a useful skill?


Out of curiosity I checked what kind of degrees Finnish presidents have had. There was (not in any particular order):

  3 law, doctor
  2 law, master
  2 law, candidate (~bachelor)
  1 agriculture, doctor
  1 social sciences, doctor
  1 none, farmer + bank manager
  1 military, field marshal 
  1 teacher (primary school)


Many politicians are former lawyers and it seems to me like passing a bar exam is a pretty useful skill (more useful than playing the sax, even) if you're going to endeavor to make laws.


Can someone (less lazy than me) try running it against this puzzle?

http://www.telegraph.co.uk/news/science/science-news/9359579...

It's been over a year since I've thought about solving sudoku, but here's how I solved it then:

https://github.com/wblakecaldwell/c-sudoku-solver


https://gist.github.com/pegler/752ae571c5d6028ebe72

Row[1] : 800000000

Row[2] : 003600000

Row[3] : 070090200

Row[4] : 050007000

Row[5] : 000045700

Row[6] : 000100030

Row[7] : 001000068

Row[8] : 008500010

Row[9] : 090000400

8-- --- ---

--3 6-- ---

-7- -9- 2--

-5- --7 ---

--- -45 7--

--- 1-- -3-

--1 --- -68

--8 5-- -1-

-9- --- 4--

812 753 649

943 682 175

675 491 283

154 237 896

369 845 721

287 169 534

521 974 368

438 526 917

796 318 452

Level Counts:

(8, 7): 1 (7, 7): 2 (7, 2): 3 (7, 5): 5 (2, 2): 7 (6, 2): 11

(1, 2): 20 (1, 7): 33 (6, 7): 51 (4, 7): 62 (2, 7): 86 (5, 2): 114

(8, 2): 160 (5, 3): 195 (5, 8): 217 (5, 9): 260 (5, 1): 317 (5, 4): 371

(4, 8): 398 (4, 9): 456 (6, 9): 473 (6, 1): 440 (6, 3): 429 (6, 5): 407

(6, 6): 392 (4, 3): 364 (4, 1): 360 (7, 6): 330 (7, 1): 302 (2, 1): 264

(7, 4): 229 (8, 5): 200 (4, 5): 164 (1, 5): 134 (2, 5): 115 (2, 6): 92

(1, 6): 71 (3, 6): 63 (4, 4): 47 (1, 3): 41 (8, 6): 37 (3, 4): 28

(3, 1): 20 (8, 9): 15 (2, 9): 12 (2, 8): 7 (1, 8): 4 (3, 9): 4

(3, 8): 1 (8, 1): 1 (1, 9): 1 (9, 1): 1 (1, 4): 1 (9, 3): 1

(9, 4): 1 (9, 5): 1 (9, 6): 1 (3, 3): 1 (9, 8): 1 (9, 9): 1

Count = 7826

Total Count = 13080


Decided to try this puzzle against an implementation of the DLX algorithm I put up a while back.[1] Looks at 2,825 board states, in total. If I stop it at the solution, only looks at 1,489 states.

[1] http://taeric.github.io/Sudoku.html


Remarkable. He uses lots of bitwise operations in the application.


He's using integers as sets of (small) integers,

    int Possibles = Block[BlockIndex] & Row[RowIndex] & Col[ColIndex];
    while (Possibles) {
        int valbit = Possibles & (-Possibles); // Lowest 1 bit in Possibles
        Possibles &= ~valbit;
        Entry[Square] = valbit;
        Block[BlockIndex] &= ~valbit;
        Row[RowIndex] &= ~valbit;
        Col[ColIndex] &= ~valbit;
is more generally:

    set<int> possibles = block[block_index].intersect(row[row_index]).intersect(col[col_index]);
    while (!possibles.is_empty())
    {
        int value = possibles.pop();
        entry[square] = value;
        block[block_index].remove(value);
        row[row_index].remove(value);
        col[col_index].remove(value);


For people who are criticizing this, try to find something good on it: it's just a curiosity about a powerful man of a well succeed country, that can inspire someone.

This also can be considered as a positive fact for me, once in my country, it's common to find politicians that even doesn't have any degree (including a very recent president).


Looks more like C than idiomatic C++ at a first glance.


A very quick glance suggests to me that the only thing C++ specific there is the filename extension (although a C compiler would do a more thorough check than I do; and faster, even!)


And the single-line comments, if not using a C99-compliant compiler. I wouldn't be surprised if he was using Visual C++ and had to change the extension to support a comment syntax that doesn't make you want to strangle yourself.


By the way, supposedly, he wrote this "years ago".


Was going to comment exactly the same thing


Capitalised identifiers? Global variables? Inconsistent indentation? PM of Singapore needs a better style guide.


Now, could someone with his age and experience get a job in Silicon Valley? The answer is precisely what is wrong in today's tech firms. Ageism must die.


Yes. Absolutely.

Experience managing the resources of a population of 5.5 million, experience on the world stage, programming and problem solving ability, his alma mater include Cambridge and Harvard, and military service, able to maintain close relationships with important people (including the President of the United States.)

He would absolutely get a job in Silicon Valley.


He would, sure. But does anyone care about the thousands that have been dismissed due to their age?


People with agendas making aggressive comments on barely related subjects to incite arguments which accomplish nothing are precisely what is wrong with todays online discussion.


He has a lot of experience in management positions, and was the Senior Wrangler in Cambridge. I bet you dollars to donuts he could get a job in SV.


Not him specifically, someone of the same age or even 10 years younger and same experience in C++ programming.


and the same management and entrepreneurial chops? Investors care about one thing: Money. If you can demonstrate to them less risk and more financial gain, they'll throw their money at you. Age has nothing to do with it. In the absence of knowing, they'll throw their money at anyone who can sell them on a lucrative vision and that person's ability to deliver that vision.


What strategy is this solver using? Is it a brute-force approach? Are there heuristics used?


I think it's neat and could draw more people to CS, but yeah, people, let's not get overexcited over this. Knowing how to write a Sudoku solver in C++ says nothing, positive or negative about him as a prime minister


I've been a (reasonably successful) programmer for 20+ years and I don't even know how to play Sudoku, nor does learning interest me... not being able to write a Sudoku solver bears no resemblance on ones capabilities. This goes the same as being able to write one. So I agree, getting excited about this seems somewhat... irrelevant. Being able to write any kind of computer program doesn't demonstrate being capable of effective leadership. Having a compelling vision for one's country, understanding the issues you will need to overcome to get there and inspiring the people to help you take it there are far more relevant to me.

Knowing a bit of C++ and understanding an algorithm to make it solve a puzzle is largely useless in this context. Understanding a bit about technology at (close to) the lowest level, doesn't signify an understanding of how the internet works, how encryption systems work, how network security or the communications infrastructure works. Without an understanding of these in today's world of the communications and the internet, you may as well not understand how to program at all. Where we see technology failing the people (certainly in North America) are because legislators are largely incompetent in this context and seek to protect corporate interests over the needs of the people. I would say, being a systems administrator or systems analyst would make you far more capable of understanding the implications of technical bills and regulations than understanding a bit of C++.


Cool PM to have :)


Buffer overflow on line 83. Input length is not checked but it must not be more than 79 characters long.


Sudoku2.cpp: In function 'void PrintStats()': Sudoku2.cpp:98:12: warning: unused variable 'j' [-Wunused-variable] int i, j, S; ^


Is there proof that this is his?


He was the top of his year in Mathematics at Cambridge, which is pretty damn hardcore. So its definitely feasible that he could bang out some C++ code.


He posted on Facebook, with screenshot of DevCpp.

https://www.facebook.com/leehsienloong/photos/a.344710778924...


Posted on his official Twitter account: https://twitter.com/leehsienloong/status/595166789660647426


Short of getting whipped, even the PM will learn to code. <sarcasm>


Meanwhile, in the U.S. a president barely has the ability to access a computer due to the ridiculous regulations surrounding them.


Can any of the 20-some candidates for 2016 code? (Not that it is important.)


Details please?


What a fascinating world this will be.


Politicians and important folk recognise the power and awesomeness of C++, and don't waste time on Ruby, Go, Rust or other time waster languages!


Globals and, more serious offense, braces on newline!


This is awesome and I don't wanna hate but the question has to be asked why c++?

There are tens more languages that are more modern and "aspirational"


Little bit off topic but, Google Drive is giving me 500 error.

It was long time ago I read that Google was directly rejecting the CVs that have typos in them which I find it annoying and not nice. And today I see this title typo in their error page which is totally fine and a mistake that i also make sometimes (leaving shift button little early while pressing 1)

<title>Error 500 (Server Error)!!1</title>

"For Google — a company that sees 50,000 résumés a week — the typo is one of five résumé mistakes that will immediately land yours in the "no" pile." [0]

http://www.businessinsider.com/google-resume-mistake-2014-9?...

Human beings will make mistakes Google, there is no need to extremely force it to otherwise.


!!1 and variations thereof are intentional, it's a joke about being so excited you can't hold shift any longer.


I would suspect that was intentional.


hmm, when i think about it now, maybe it was!!1


Occasionally you'll also come across someone who beats the joke to death just to make their point!!!1111OneOneEleven


It's deliberate. One of those "internet culture" things. Engineers are allowed to have a bit of humour sometimes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: