DEV Community

loading...

Discussion on: Daily Challenge #214 - Persistent Bugger

Collapse
vidit1999 profile image
Vidit Sarkar

Python solution

from functools import reduce
persistence = lambda num: 0 if num < 10 else 1 + persistence(reduce(int.__mul__,map(int, str(num))))

print(persistence(39)) # output 3
print(persistence(999)) # output 4
print(persistence(4)) # output 0
print(persistence(5)) # output 0
print(persistence(52)) # output 2
print(persistence(377)) # output 4