Files
freeCodeCamp/curriculum/challenges/chinese/10-coding-interview-prep/project-euler/problem-22-names-scores.md

852 B
Raw Blame History

id, title, challengeType, videoUrl
id title challengeType videoUrl
5a51eabcad78bf416f316e2a 问题22命名分数 5

--description--

使用names 包含超过五千个名字的数组首先按字母顺序排序。然后计算每个名称的字母值将该值乘以列表中的字母位置以获得名称分数。例如当列表按字母顺序排序时值为3 + 15 + 12 + 9 + 14 = 53的COLIN是列表中的第938个名称。因此COLIN将获得938×53 = 49714的分数。文件中所有名称分数的总和是多少

--hints--

namesScores(test1)应该返回791。

assert.strictEqual(namesScores(test1), 791);

namesScores(test2)应该返回1468。

assert.strictEqual(namesScores(test2), 1468);

namesScores(names)应返回871198282。

assert.strictEqual(namesScores(names), 871198282);

--solutions--