You are viewing a single comment's thread. Return to all comments →
My initial idea was to use str to convert to a string and reverse using indexing and convert back:
import os def beautifulDays(i, j, k): num_beautiful_days = 0 for num in range(i, j+1): num_reverse = int(str(num)[::-1]) if abs(num-num_reverse) % k == 0: num_beautiful_days += 1 return num_beautiful_days if __name__ == '__main__': fptr = open(os.environ['OUTPUT_PATH'], 'w') first_multiple_input = input().rstrip().split() i = int(first_multiple_input[0]) j = int(first_multiple_input[1]) k = int(first_multiple_input[2]) result = beautifulDays(i, j, k) fptr.write(str(result) + '\n') fptr.close()
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Days at the Movies
You are viewing a single comment's thread. Return to all comments →
My initial idea was to use str to convert to a string and reverse using indexing and convert back: