现年 63 岁的新加坡总理李显龙多年前用 C++ 写的解数独小程序。源码:https://drive.google.com/folderview?id=0B2G2LjIu7WbdfjhaUmVzc1lCR2hUdk5fZllCOHdtbFItbU5qYzdqZGVxdmlnRkJyYVQ4VU0&usp=sharing&usp=sharing&urp=https://drive.google.com/folderview?id%3D0B2G2LjIu7W#list
Quoted from his speech on Smart Nation on 20 April:
"... I have set up the Smart Nation Programme Office, to bring all the pieces together, within Government, and also between Government and the private sector, to use technology to achieve social and economic objectives, and to make a difference in all our lives. The Smart Nation Programme Office lives in the Prime Minister’s department. I take a personal interest in this. 40 years ago, after doing a math degree, I went on to study computer science, on my father’s advice. He said there is a future in that, and he was right. So for the Smart Nation Programme Office, I have put Minister Vivian Balakrishnan in charge, reporting to me. Vivian is both a hacker and a dabbler – He used to be an eye surgeon but since he does not get to operate on eyes nowadays, he dabbles in building simple robots, assembling watches, wireless devices and programming apps. His day job is to be the Minister for the Environment and Water Resources, and so when he builds apps, he uses the real time APIs generated by the Ministry. That’s called user-testing. I used to enjoy this; it is a long time since I’ve done anything. The last programme I wrote was a Sudoku solver in C++ several years ago, so I’m out of date. My children are in IT, two of them – both graduated from MIT. One of them browsed a book and said, “Here, read this”. It said “Haskell – learn you a Haskell for great good”, and one day that will be my retirement reading. ..."
李显龙明显是一直以来对数学和cs很有兴趣的。能力完全不用怀疑,剑桥1973年的Senior Wrangler -- 数学课程的top one,学神级别的, 之后还有CS的diploma (with distinction)。有兴趣的可以搜搜历年的senior wrangler得主,很多都成为数学或者物理学教授了。我觉得如果他不是新加坡总理,完全有可能成为一个数理方面的成功学者。
插播一个,李显龙在Cambridge读书的时候mentor是Béla Bollobás。Bollobás是Erdős的学生,Gowers的老师。他在一个采访里面说李显龙当年在剑桥就很厉害,如果不回去当总理应该也会成为出色的数学家。Bollobás在采访中说过李显龙的水平比第二名高很多,而且当时是很有可能成为杰出的数学家。他甚至劝过李光耀让李显龙去搞纯数学。 I’m sure his father never
realized how exceptional Loong was. He thought Loong was
very good. No, Loong was much better than that. When I
tried to tell Lee Kuan Yew, “Look, your son is phenomenally
good: you should encourage him to do mathematics”(http://195.134.81.187/data/articles/ql-nmtgnddo.pdf.pdf)
再安利一下:Paul Erdős不用介绍,传奇人物。Timothy Gowers,菲尔兹奖得主,著名数学博客Gowers's Weblog on WordPress.com创建人。他的wordpress和陶哲轩的博客齐名。他的学生Ben Green也曾是菲尔兹奖热门得主,陶哲轩当年的菲尔兹奖的一个著名结果Green-Tao Theorem中的Green是也。
LeetCode Hard 级别 K.O. - Sudoku Solver
根据他的年龄、毕业时间,以及C发明和流行的时间,还是无法判断他是在什么时候写的水平怎么样也不好说,毕竟他没专门从事程序员行业编程水平,基本还是靠多年的实践才能提升、巩固的
后来看到一段 直接快速解数独 的C代码,大家可以比较一下:#include
int cc=0;
#define M(g,k) (b[g%9]|b[(g/9)+9]|b[18+(g/27)*3+((g%9)/3)])&c[k]#define L(g,k) b[g%9]^=c[k],b[(g/9)+9]^=c[k],b[18+(g/27)*3+((g%9)/3)]^=c[k]int t(int i,int p){ int k; if(i>81){// putA(); return 1;/** got it */ } while(p<81&&a[p])p++;
printf("%d=%d %d\n",++cc,i,p);
for(k=9;k;--k){ if(!(M(p,k))){ a[p]=k; L(p,k); if(t(i+1,p+1)) return 1; a[p]=0; L(p,k); } }
return 0;}
李光耀的自传中有一句话,大意是:我在显龙出生那一年给我的导师写了封信,为他在剑桥大学预定了一个十七年后的位置。
已经完爆90%的程序员了,我熟悉的同事没一个能写出来吧
水平不是太高,应为他的解法是很直白的,但是对于一些特殊的输入出结果比较慢
速度快的解法是dlx来做,或者其他优化。
===========================================================
欧阳丹
李显龙是剑桥数学系 1st class,并且修了computer science 双学位。这个程序说明他还没有把学生时代的东西忘记。这么多年从政,很不容易其实。
-----
很多人说不咋样。其实是不咋样,并且这明明是C,和C++基本没关系。
但是你要知道一件事情。李显龙本科的时候按时间算应该40年前,也就是1975年左右(查了下李显龙1974年大学毕业)。查查C语言历史:
在1972年,美国贝尔实验室的 D.M.Ritchie 在B语言的基础上最终设计出了一种新的语言,他取了BCPL的第二个字母作为这种语言的名字,这就是C语言。
也就是说,李显龙读大学的时期,计算机系基本是不可能教你C语言的。那个年代的算法研究和现代比也是天差地别。那个年代的算法更多的是简单数据结构,如何生成随机数,等最“原始”最“朴素”的算法。
所以他的编程水平,在现在的计算机世界不值得一哂,但是考虑到他毕业的年代,和职业历程,对任何一个人有他相同的经历来说,已经接近于挑战一个人的极限了。
-----