Beautiful Days at the Movies : HackerRank Solution in Python

Solution in Python 3

def beautifulDays(i, j, k):
beautifulDays = 0
for day in range(i, j+1):
rev = int(str(day)[::-1])
if abs(rev-day)%k==0:
beautifulDays+=1

return beautifulDays

Explanation

def beautifulDays(i, j, k):
beautifulDays = 0
for day in range(i, j+1):
rev = int(str(day)[::-1])
if abs(rev-day)%k==0:
beautifulDays+=1
return beautifulDays

pretending to teach is one of the best way to learn.