Search results
We perform the following calculations to determine which days are beautiful: Day 20 is beautiful because the following evaluates to a whole number: |20 – 02| /6 = 18/6 = 3. Day 21 is not beautiful because the following doesn’t evaluate to a whole number: |21 – 12|/6 = 9/6 = 1.5.
Jul 31, 2024 · In this HackerRank Beautiful Days at the Movies problem you have Given a range of numbered days, [i…j] and a number k, to determine the number of days in the range that are beautiful. Beautiful numbers are defined as numbers where |i-reverse(i)| is evenly divisible by k.
#!/bin/python3 import math import os import random import re import sys from decimal import * # Complete the beautifulDays function below. def beautifulDays (i, j, k): count=0 for l in range (i,j+1): n = (str (l) [::-1]) if (abs (l-int (n))%k ==0): count+=1 return count if __name__ == '__main__': fptr = open (os.environ ['OUTPUT_PATH']...
k = int (first_multiple_input [2]) result = beautifulDays (i, j, k) fptr.write (str (result) + '\n') fptr.close () A collection of solutions to competitive programming exercises on HackerRank. - hackerrank-solutions/challenges/beautiful-days-at-the-movies.py at master · kilian-hu/hackerrank-solutions.
# She will look at a numbered range of days and will only go to a movie on a beautiful day. # Given a range of numbered days, [i...j] and a number 'k', # determine the number of days in the range that are beautiful.
Function Description. Complete the beautifulDays function in the editor below. beautifulDays has the following parameter (s): int i: the starting day number. int j: the ending day number. int k: the divisor. Returns. int: the number of beautiful days in the range. Input Format.
Aug 8, 2020 · Given a range of numbered days, [i…..j] and a number k, determine the number of days in the range that are beautiful. Beautiful numbers are defined as numbers where |i – reverse(i)| is evenly divisible by k.