My dad is a retired teacher, and he used to give combined spelling and math quizzes, where the student would spell a word, and then 'score' the word by adding up the letters, where a=1, b=2, etc. (e.g. cat = 3+1+20=24). This made grading the quizzes easier, as he would just have to check for incorrect 'scores' rather than incorrectly spelled words, and had the added benefit of testing 2 skills at once.
He hired a friend of mine to write a program that would score words for him, so he could generate lengthy answer keys without error. This problem is inspired by that program.
Requirements:
- Accept any word with uppercase and lowercase letters
- Return an error for any special characters, i.e. spaces, hyphens, @^%# etc.
- a=1, b=2,... and A=1, B=2,...
- Print the score of the word
- (Optional) check that the word is in a dictionary after scoring, and print a warning if it is not.
- No importing an external letter->number dictionary. You must generate it yourself.
Any language is acceptable. This is similar to the 'digital root battle,' but much simpler.
code-golf
tag. \$\endgroup\$aaaaaaaaaaaaaaaaaaaaaaaa
. Dad: Score is 24? That's right! \$\endgroup\$