나는 이렇게 학습한다/Algorithm & SQL

0922. Love vs friendship

daco2020 2022. 9. 22. 22:20
반응형

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)


반응형