2014-05-10 06:51
原题:
"How would you find the number of gas stations in the United States?" *You cannot look up any concrete information (like the average number of gas stations per state), but you need to yield an accurate answer.
题目:你要如何搞清楚美国有多少个加油站?不准查,不准问。
解法:这个题很出名,是外行人眼里的奇葩智力题。起初我也觉得这题就是智力题,但是读了《编程珠玑》之后明白了这题是对于估算能力的考察。个人觉得估算需要三个条件:1. 发现有关联的变量。2. 明确变量构成的公式。3. 估算各个变量的值,然后计算公式结果。我想到了人口、国土面积、人口密度、之类的变量,但是没法确定加油站的数量到底和哪一个直接相关,所以还是没有办法构造公式。参考了答案以后,算是有了个结论:加油站和人口相关。这个结论真的可靠?
代码:
1 // http://www.careercup.com/question?id=5680049562845184 2 Answer: 3 The number of gas stations is related to population, instead of area of land. 4 Thus you have to find out the average density of gas stations by population. 5 6 Here's the answer from another user: 7 From the US census you can look up what is the average density of gas station / population ( some number ). Multiply that by the population and you get the answer. 8 10 gas stations / 1000 people * (300,000) = 3000 gas stations. Although this answer will be within the standard deviation and you will have to find the upper and lower limit 9 +- std.dev. 10 Another way would be to do data mining. Either way you need some information, you cannot pull a number out of thin air. Well, unless you travel through each and every street and corner of the country. 11 Another great idea: gather telephone books from each and every area of the US and count the number of gas stations in each region and add them up. Not all gas stations are labelled gas stations. 12 So, pick and choose, or maybe another idea!!