思维模型~提升视角新维度

思维模型会给你提供一种视角或思维框架,从而决定你观察事物和看待世界的视角。顶级的思维模型能提高你成功的可能性,并帮你避免失败。                                                   查理·芒格

打造多元思维模型想法来自查理·芒格,而查理·芒格是沃伦·巴菲特的得力助手。Farnam Street曾这样描述思维模型:“思维模型是你大脑中用于做决策的工具箱。你拥有的工具箱越多,你就越能够做出正确的决策。” 继续阅读“思维模型~提升视角新维度”

正则表达式简述

字符串是编程时涉及到的最多的一种数据结构,对字符串进行操作的需求几乎无处不在,比如判断一个字符是否是合法的Email地址,虽然可以编程提取@前后的子串,再分别判断是否是单词和域名,但这样做不但麻烦,而且代码难以复用。

正则表达式(regular expression)就是用一个“字符串”来描述一个特征,然后去验证另一个“字符串”是否符合这个特征。故判断一个字符串是否是合法的Email的方法是:

1、创建一个匹配Email的正则表达式;

2、用该正则表达式去匹配用户的输入来判断是否合法。

正则表达式可以用来:(1)验证字符串是否符合指定特征,比如验证是否是合法的邮件地址。(2)用来查找字符串,从一个长的文本中查找符合指定特征的字符串,比查找固定字符串更加灵活方便。(3)用来替换,比普通的替换更加强大。 继续阅读“正则表达式简述”

Principles of Algorithm Analysis I

Analysis plays a role at every point in the process of designing and implementing algorithms. At first, as we saw, we can save factors of thousands or millions in the running time with appropriate algorithm design choices. As we consider more efficient algorithms, we find it more of a challenge to choose among them, so we need to study their properties in more detail. In pursuit of the best ( in some precise technical sense ) algorithm, we find both algorithms that are useful in practice and theoretical questions that are challenging to resolve. 继续阅读“Principles of Algorithm Analysis I”