昨天在酷壳逛逛,看到版主推荐一个网站,在线做一些算法题目,于是出于好奇就去看看,一下子就被吸引了。
从上往下看,题目是检测配对的括号,这个页面是提交方案成功之后给出的统计表。我之前一直很好奇一个问题:你是怎么知道我写的程序对不对,好不好?看图最上的方框没有,那个就可以解释了。一共65个测试用例,几乎覆盖了所有的情况,一旦满足测试用例就是正确的算法,把主观评价变成了客观的评价,西方先进思想在计算机上体现最为明显,可惜在中国还是要看领导是否SB,呵呵。下面一个看最大的箭头,你的测试成绩在这里,用了2ms,这就是“好不好”的问题,完成这些用例耗时越少就越好。可以看到我的属于在C++语言里面是平均值,也没有啥特别算法,就是正常思路处理。
下面就是几个常见争论:C语言就是比C++快,脚本语言比较慢,Java就是很慢,可是从来都没有直观的解释。今天看到用例完成时间的对比,你看一眼就知道,那个慢的都不在一个数量级上,一个程序是由一个一个小算法构成的,也就基本确定了语言本身的优势和劣势吧。
上一个小用例是把123,这样整数变成321,一共1000多个测试用例,天啊,怪不得人家快速迭代敏捷开发都要求先写测试用例后开发,如果你每个模块都是正确的,组合起来的程序,想错也错不了啊!对比一下我们的开发方式,呵呵,我们还在刀耕火种,人家已经机械化生产了。最奇怪的是,我们还沾沾自喜,自命老子天下第二,没人敢称第一,真是井底之蛙,夜郎自大。