Matching Letter Gaps
Instead of comparing the letters themselves, you can compare the distances between neighboring characters by their character codes. The function funny_string receives a string s and computes the absolute differences between adjacent character codes for both s and its reversed version. If the two difference sequences are the same, return Funny; otherwise return Not Funny.
Примеры
Ввод
"acxz"Вывод
"Funny"Ввод
"bcxz"Вывод
"Not Funny"Ввод
"ivvkxq"Вывод
"Not Funny"Нужно реализовать
def funny_string(s: str) -> str:
Теги
strings
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
"acxz"Expected
"Funny"2
Input
"bcxz"Expected
"Not Funny"3
Input
"ivvkxq"Expected
"Not Funny"4
Input
"a"Expected
"Funny"5
Input
"aba"Expected
"Funny"6
Input
" "Expected
"Funny"Focus radio
Paused · SomaFM · Fluid