If a = 1, b = 2, c = 3 ... z = 26
Then l + o + v + e = 54
and f + r + i + e + n + d + s + h + i + p = 108
So friendship is twice stronger than love :-)
The input will always be in lowercase and never be empty.
Solution:
def words_to_marks(s: str, ord_num: int = 96):
return sum(ord(i)-ord_num for i in s)
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
| 0924. Sum of positive (0) | 2022.09.24 |
|---|---|
| 0923. Sum of differences in array (0) | 2022.09.23 |
| 0921. Sum without highest and lowest number (0) | 2022.09.21 |
| 0920. Difference of Volumes of Cuboids (0) | 2022.09.20 |
| 0919. Cat years, Dog years (0) | 2022.09.19 |