|
发表于 2016-6-16 19:09:50
|
显示全部楼层
本帖最后由 mather 于 2016-6-17 09:43 编辑
- path = r'C:\Users\CloudCross\Desktop\names.txt'
- textFile = open(path)
- try:
- all_the_text = textFile.read()
- finally:
- textFile.close()
- data = all_the_text.replace('"','').split(',')
- import numpy as np #这个包你可能没有,如果有就当我没说,没有的话你可以去下载一个,数据分析必备
- arr = np.array(data)
- sortedarr = np.sort(arr)
- from functools import reduce
- zimuzhi = np.array([reduce(lambda a,b: a+b,list(map(lambda y: y-64,list(map(ord,x))))) for x in sortedarr])
- index=np.arange(1,len(sortedarr)+1)
- print((index * zimuzhi).sum())
复制代码
最终结果:871198282 |
评分
-
查看全部评分
|