Feeds:
Posts
Comments

ref: http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=planApproach1

Here’s your first exercise: take any problem in the Practice Rooms that you
haven’t done. Fight through it, no matter how long it takes, and figure it
out (use the editorial from the competition as a last resort). Get it to
pass system tests, and then note how long you took to solve it. Next, clear
your solution out, and try to type it in again (obviously cutting and
pasting will ruin the effect). Again, get it to pass system tests. Note how
long it took you to finish the second time. Then, clear it out and do the
problem a third time, and again get it to pass system tests. Record this
final time.

The time it takes for your first pass is how long it takes you when you have
no expectations of the problem and no approach readily in mind. Your time
on the second pass is usually the first time minus the amount of time it
took you to understand the problem statement. (Don’t be surprised at the
number of bugs you’ll repeat in the second pass.) That final recorded time
is your potential, for you can solve it this fast in competition if you see
the correct approach immediately after reading it. Let that number encourage
you; it really is possible to solve some of these problems this quickly,
even without super fast typing ability. But what you should also learn from
the third pass is the feeling that you knew a working strategy, how the code
would look, where you would tend to make the mistakes, and so on. That’s
what it feels like to have the right approach, and that feeling is your goal
for future problems in competition.

In most martial arts, there’s a practice called kata where the martial
artist performs a scripted series of maneuvers in order, usually pretending
to defend (or sometimes actually defending) against an onslaught of fighters
, also scripted to come at the artist predictably. At first this type of
practice didn’t make any sense, because it didn’t seem realistic to the
chaotic nature of battle. Furthermore it seems to encourage the type of
pattern mining mentioned in the previous section. Only after triple-coding
many problems for a while can one comprehend the true benefit of this coding
kata. The kata demonstrates to its practitioners the mental experience of
having a plan, encouraging the type of discipline it takes to sit and think
the problem through. This plan of attack is your approach, and it carries
you through your coding, debugging, and submission.

非常好地揭示该怎么苦练。

Advertisements

 

– 即使你名花有主,我也要移花接木,行吗?

– 為什麼我這麼帥 難道是命運的安排?哦,我的天哪 每天都被自己帥醒 鸭梨真的好大!我急死了,我该怎么办?

– 住在我心里,你交房租了吗?

– 我颠倒了整个世界,只为摆正你的倒影。

– 等哥这次挣钱,咱买棒棒糖。买两根,一根你看着我吃,另一根,我吃给你看。

– 有福同享,有难同当。大大泡泡糖,迷你真知棒。

– 你不要这么悲观,用扯蛋的态度,面对操蛋的人生。那是行不通的。

– 如果不是哥长年潜水,变得这么有深度有内涵,早变成蝴蝶飞走了。

– 真相会让我们痛苦一阵,谎言会让我们痛苦一生。

他的一生向我揭示了一个我所体验过的最富有启发性的寓言。
我第一次遇见贾金斯,或者说真正注意他,是在好些年前,那时我还是个孩子,正在外边野营。当时有人正要将一块木板钉在树上当搁板,贾金斯便走过去管闲事,说要帮他一把。
“停一停,”他说道,“你应该先把木板头子锯掉再钉上去。”于是,贾金斯便四处去找锯子。找来锯子之后,还没有锯到两三下又撒手了。“这把锯子,”他说,“需得磨快些。”于是他又去找锉刀。接着又发现在使用锉刀之前,必须先在锉刀上安一个顺手的手柄,为了给锉刀安手柄,他又去灌木丛中寻找小树,要砍下小树干,他又发现这得先磨快斧头。当然,要磨快斧头,他不得不先将磨石固定好,这样磨起来才得心应手;可这又免不了要制作几根支撑磨石的木条。为了把这事儿办得体面些,贾金斯决定做一张木匠用的长凳;可这没有一套齐全的工具是不可能的事。于是,贾金斯到村里去找他所需要的工具,然而这一走,就再也不见他回来了。
几个星期以后,人们才看见他在城里露面;为了成批购买器械,他正在讨价还价。
自从第一桩事儿以后,我逐渐和贾金斯混熟了,十分了解他无论学什么都是半途而废。曾有一段时间,他废寝忘食地攻读法语,但很快便发现要真正掌握法语,必须首先对古法语有透彻的了解,然而实践表明:没有对拉丁语的全面掌握和理解,要想学好法语是绝不可能的。贾金斯进而发现,掌握拉丁语的唯一途径是学习梵文,因为梵文显然是拉丁语的基础。因此贾金斯便一头扑进梵文的学习之中,直到他发现,要正确地理解梵语,非学古伊朗语不可,因为它是语言的根本。然而,这种语言却早已销声匿迹了。
这样,贾金斯不得不一切从头开始。无可否认,他的确在自然科学上取得过一些成绩。他研究过物理学,很快从对力的研究追溯到分子,又从分子到原子,再从原子到电子,当他的全部研究已扩展到无限的空间领域时,他却仍然在那里追根溯源。
不用说,贾金斯从未获得过什么学位,他所受过的教育也始终没有用武之地。
但这无关紧要。他有的是钱,可以拿出10万美元的资本直接开厂兴业。起初,他将这笔钱投资办一家煤气厂,可他发现造煤气所需的煤炭价钱昂贵,这使他大为亏本。于是,他以9万美元的售价把煤气厂转让出去,开办起煤矿来。可这又不走运,因为采矿机械的耗资大得吓人。因此,贾金斯把在矿里拥有的股份变卖成8万美金,转入了煤矿机器制造业。这样,他本来可以赚些钱的,偏偏用作工厂动力的是煤气,耗费巨大。于是贾金斯又以7万元的价卖掉他的制造业。从那以后,他便象一个倒行的滑冰者,在有关的各种工业部门中滑进滑出,没完没了。
每年他都要亏损一大笔钱,尤其是在生意兴隆的好年头。倒是在生意萧条、商品卖不出的晦气日子里,他干得挺不错。
贾金斯的家庭生活说得上风平浪静。
当然他从未结过婚。但说实话,他也恋爱过好几次,虽然每一次都毫无结果。
我还清楚地记得他的初恋故事,当时我和他过从甚密,无话不说。他对一位姑娘一见钟情,十分坦率地向她表露了心迹。“我想请求她做我的妻子。”他对我说。
“什么时候?”我问他,“就办喜事吗?”
“不,”他回答说,“我首先得使自己匹配得上她。”
为此,他开始在精神品德方面陶冶自己。他去一所星期日学校教了一个半月的课,这时他意识到,假如一个人不打算首先系统地学习巴勒斯坦历史,休想在教书这样神圣的职业中干出一番事业。他还认为,当一个人对以色列的历史还只是一知半解,想去追逐一个女人,那真是无赖之徒。因此,贾金斯自动逃遁了。当他认为问心无愧、无妨启齿求婚之日,整整将近两年的光阴已经流逝了。这时,那位姑娘早已嫁给一个愚蠢的家伙,脚上穿着漆皮长靴。
自然,贾金斯又再次坠入情网。无论如何,这一回他的思想品德是满够格的了。
这一次他如痴如醉地爱上了一位迷人的、有5个妹妹的姑娘。无论哪位名副其实的男子汉,准会一见钟情地爱上象她这样的姑娘。既然如此,贾金斯一定会向姑娘求婚的。可是当他上姑娘家时,遇见的却是她家的二妹。当然这位妹妹更年轻,这样贾金斯便喜欢上了二妹。可是一天晚上,当他去姑娘家拜访时,开门的是一位更小的妹妹。这一来,贾金斯只好倒回去逐个地将众姐妹衡量了一番,到最后一个也没上手。”“也许贾金斯从未结成婚倒是件好事,因为贾金斯的情形每况愈下,越来越穷,结了婚会陷入更困难的境地。你知道,他卖掉了最后一项营生的最后一份股份后,便用这笔钱买了一份逐年支取的终生年金。可是这样一来,支取的金额将会逐年减少,因此他要是活的时间长了,早晚得饿死。
与此同时,他的形象大变,看上去既老又古怪,上衣短了一截,裤子悬在破靴上,活像个瘪三,他那张脸也像个小老头,布满了道道皱纹。
而且他一谈起话来总是回忆过去,他老是没完没了地给别人讲述自己在往昔的快乐时光所经历的故事,提到各式各样的人。
譬如,他讲道──“我想起一桩相当古怪的事情:那天我在火车上遇到──”假如这时候你问:“那是什么时候的事了,贾金斯?”那么,他会用一种迷惘的目光瞅着你,好象正在推算时间,接着说道:“是1875年,也许是1876年,就我记忆所及,大致差不多是──”我还注意到,当他回忆这些往事时,总是往回追溯,越追越远。有一段时期,他讲的都是他年轻时候的往事,而今他讲的故事更加遥远了。
不久前的一天,他告诉我一个有关他和其他两位他称作哈普尔弟兄的故事,这兄弟俩一个叫勒德,一个叫乔,他说勒德这老兄力大无比。
我问勒德有多大岁数,贾金斯回答我说三岁。他还补充说另一位兄弟年龄更小,但却是个十足的机灵鬼,大约──讲到这里,贾金斯停歇下来推算,大约有18个月吧。
于是,我才明白贾金斯缅怀往昔到了何种地步。他已经从童年退到了婴儿期。
而现在,当他的年金枯竭,到了山穷水尽的地步,他也就退到了生命的底线,究竟是死是生,我便不得而知了。
然而,他的一生却向我揭示了一个我所体验过的最富有启发性的寓言。

I was at Amazon for about six and a half years, and now I’ve been at Google for that long. One thing that struck me immediately about the two companies — an impression that has been reinforced almost daily — is that Amazon does everything wrong, and Google does everything right. Sure, it’s a sweeping generalization, but a surprisingly accurate one. It’s pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn’t let me show it to anyone, even though recruiting loved it.
Continue Reading »

长期的一个误区是:Brutal force不是一个好的思考方向,如果可能,先想想其它可能。

实际上,计算机最擅长的,就是按简单规律的重复计算。怎样高效地简单计算,那是解决很多计算机问题的关键所在。

如果都希望问题归结为数学,那是不现实的。

Week 1
12 – 10 – 9 – 9 – 8
12 – 10 – 10 – 9 – 9
13 – 10 – 10 – 9 – 8

Week 2
15 – 11 – 10 – 9 – 8
15 – 12 – 11 – 9 – 8
14 – 13 – 12 – 11 – 9

Week 3
15 – 14 – 10 – 12 – 10
15 – 14 – 11 – 13 – 10
14 – 14 – 14 – 12 – 11

Week 4
17 – 10 – 16 – 10 – 14
14 – 19 – 11 – 13 – 9
19 – 11 – 14 – 13 – 11

Week 5
22 – 13 – 11 – 10 – max
24 – 10 – 11 – 13 – max
26 – 10 – 11 – 10 – max

Week 6
30 – 15 – 10 – 15 – max
33 – 16 – 11 – 13 – max
35 – 10 – 11 – 10 – max

Week 7
30 – stretch – 22 – stretch – max
34 – stretch – 20 – stretch – max
35 – stretch – 24 – stretch – max

Week 1 (odd: pull up, even: chin up), rest :90 between set.

7 – 8 – 7 – 5 – 5
8 – 8 – 7 – 7 – 4
7 – 8 – 8 – 7 – 5

Week 2

9 – 8 – 7 – 6 – 6
8 – 9 – 8 – 7 – 5
9 – 9 – 8 – 6 – 6

Week 3

10 – 8 – 7 – 6 – 6
9 – 10 – 8 – 7 – 5
9 – 10 – 9 – 7 – 6

Week 4

10 – 9 – 9 – 7 – 6
10 – 10 – 9 – 7 – 5
10 – 10 – 9 – 8 – 6

Week 5

10 – 10 – 9 – 9 – 8
10 – 10 – 9 – 9 – 9
10 – 9 – 10 – 9 – 9