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.
Ruby
Init
1 2 3
defhigh(x) # Code here end
Sample Testing
1 2 3 4 5 6 7 8
describe "Basic Tests"do it "should pass basic tests"do Test.assert_equals(high('man i need a taxi up to ubud'), 'taxi') Test.assert_equals(high('what time are we climbing up the volcano'), 'volcano') Test.assert_equals(high('take me to semynak'), 'semynak') Test.assert_equals(high('aaa b'), 'aaa') end end
Javascript
Init
1 2 3
functionhigh(x){ // Code here }
Sample Testing
1 2 3 4 5
Test.describe("Example tests",_=>{ Test.assertEquals(high('man i need a taxi up to ubud'), 'taxi'); Test.assertEquals(high('what time are we climbing up the volcano'), 'volcano'); Test.assertEquals(high('take me to semynak'), 'semynak'); });
Thinking
想法(1): 輸入的英文句子,可以先將每個字切開分群 想法(2): 再將每個群計算 ord 然後計算該群單詞 ord 總和