Reverse and Add

There is a curious process: take a number, add its digit-reversed form, and repeat. Write a function is_lychrel that returns True if no palindrome appears after max_iter iterations, treating the number as a Lychrel candidate. If a palindrome appears earlier, return False. Checking a palindrome is easy by comparing a string with its reverse.

Примеры

Ввод
47, 50
Вывод
False
Ввод
349, 50
Вывод
False
Ввод
89, 50
Вывод
False

Нужно реализовать

def is_lychrel(n: int, max_iter: int) -> bool:

Теги

mathstrings
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Visible tests
1
Input
47, 50
ExpectedFalse
2
Input
349, 50
ExpectedFalse
3
Input
89, 50
ExpectedFalse
4
Input
196, 50
ExpectedTrue
5
Input
4994, 50
ExpectedTrue
6
Input
10, 50
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid