DESCRIPTION:
Given a string of words, you need to find the highest scoring word.
Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc.
You need to return the highest scoring word as a string.
If two words score the same, return the word that appears earliest in the original string.
All letters will be lowercase and all inputs will be valid.
def high(x):
alist=x.split(' ')
blist=[]
index=0
temp=0
for i in range(len(alist)):
for j in alist[i]:
temp+=ord(j)-96
blist.append(temp)
temp=0
index=blist.index(max(blist))
return alist[index]'알고리즘 문제 > CodeWar' 카테고리의 다른 글
| Two Sum (0) | 2022.09.23 |
|---|---|
| Odd or Even? (0) | 2022.09.23 |
| Mexican Wave (0) | 2022.09.23 |
| Find the unique number (0) | 2022.09.23 |
| Consecutive Strings (0) | 2022.09.22 |