word of lowercase English letters and an integer rounds.
First, replace every letter with its position in the alphabet (a → 1, b → 2, …, z → 26) and write those numbers one after another to form one long number. For example, "cab" becomes 312.
Then, rounds times in a row, replace the number with the sum of its digits. Return the value left after the last round.word="bad", rounds=1 → 7
The letters become 2, 1, 4, giving 214. Its digit sum is 2 + 1 + 4 = 7.
word="zoo", rounds=2 → 2
z = 26, o = 15, o = 15, giving 261515. Round one: 2 + 6 + 1 + 5 + 1 + 5 = 20. Round two: 2 + 0 = 2.
word="k", rounds=3 → 2
k = 11, then 1 + 1 = 2, and 2 stays 2 from then on.
word consists of lowercase English lettersword="bad", rounds=1
7
Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.