Input: A string
Output: The rarity of the string, as described below.
To find the rarity of a string, follow the steps below.
- Start with 0.
- Subtract 3 for each E, A, T, or O in the string.
- Subtract 2 for each I, N, S, or H in the string.
- Subtract 1 for each R, D, L, or C in the string.
- Add 1 for each W, F, G, or Y in the string.
- Add 2 for each K, V, B, or P in the string.
- Add 3 for each J, Q, X, or Z in the string.
Test cases:
Input: "rarity"
Output: -9
Input: "aardvark"
Output: -8
Input: "quine"
Output: -4
Input: "wow"
Output: -1
Input: "why"
Output: 0
Input: "puppy"
Output: 7
Scoring:
This is code-golf. The shortest answer in bytes wins!
Clarifications:
- The input only consists of lowercase letters.
- The input is guaranteed to be non-empty.
- For U and M, do nothing.
- The text can be in any format.
u
in them, despite the challenge not mentioning how to handleu
. How isu
(and alsom
, which isn't in the 24 letters provided) handled? \$\endgroup\$