#K171. Mana Cost Calculation
Mana Cost Calculation
Mana Cost Calculation
You are given a spell represented as a string of lowercase English letters. The mana cost of the spell is defined as the sum of the values of its unique characters, where each character has a value corresponding to its position in the English alphabet, i.e. $a=1$, $b=2$, ..., $z=26$. For example, the mana cost of the spell abc
is $1+2+3=6$, and the mana cost of aabbcc
is also $6$ because repeated characters are only counted once.
Your task is to compute the mana cost for each spell provided in the input.
Input: The first line contains an integer $T$, representing the number of spells. Each of the following $T$ lines contains a single string that represents a spell.
Output: For each spell, output its mana cost on a new line.
inputFormat
The input consists of multiple lines:
- The first line contains an integer $T$ ($1 \le T \le 1000$) – the number of spells.
- Each of the next $T$ lines contains a non-empty string of lowercase letters representing a spell.
outputFormat
For each spell, output a single integer on a new line, representing the mana cost, which is the sum of the values of its unique characters. The mapping is given by: $a=1$, $b=2$, ..., $z=26$.
## sample1
abc
6
</p>