mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
1.2 KiB
1.2 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69c6ff713a52713463aa7926 | Challenge 260: Word Score | 29 | challenge-260 |
--description--
Given a word, return its score using a standard letter-value table:
| Letter | Value |
|---|---|
| A | 1 |
| B | 2 |
| ... | ... |
| Z | 26 |
- Upper and lowercase letters have the same value.
--hints--
get_word_score("hi") should return 17.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_word_score("hi"), 17)`)
}})
get_word_score("hello") should return 52.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_word_score("hello"), 52)`)
}})
get_word_score("hippopotamus") should return 169.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_word_score("hippopotamus"), 169)`)
}})
get_word_score("freeCodeCamp") should return 94.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(get_word_score("freeCodeCamp"), 94)`)
}})
--seed--
--seed-contents--
def get_word_score(word):
return word
--solutions--
def get_word_score(word):
return sum(ord(c) - 96 for c in word.lower())