PM of Singapore Shares His C++ Sudoku Solver Source Code
drive.google.com
drive.google.com
Previously on HN: https://news.ycombinator.com/item?id=9419035
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.
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.
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.
He is a senior wrangler.
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.
But in reality, you should indeed stick with the "4 spaces" PEP8 compliant style.
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.
> 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.
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.
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.
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.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)
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?
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.
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).
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
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.
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.
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 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.
`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.
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.
It is easy to be an anarchist or communist when you dont have to live in such a place.
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).
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?
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.
[0] - http://thehearttruths.com/2013/02/21/singapore-has-the-highe...
> 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.
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 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.
Anyway, it appears that I'm now treading on people's toes so that's enough from me.
Enough for me, too.
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.
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...)
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).
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.
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.
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 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.
"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...
Just as long as you're of Chinese ancestry, of course.
Singapore isn't a free country. It's very efficient, rich and safe, yes.
"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".
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.
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.
Speaking in public (especially to very large crowds) and not turning into a nervous wreck is not a useful skill?
The general public don't think of you as some sort of magic hacker because you code for a living, sorry.
"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?
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)So yeah, extra curricular skills and fancy degrees and academic credentials may not translate into a good leader of the country.
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:
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
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);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).
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.
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++.
https://www.facebook.com/leehsienloong/photos/a.344710778924...
There are tens more languages that are more modern and "aspirational"
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.