Algorithms
Beautiful Days at the Movies
seoca
2020. 10. 18. 18:41
Solution in Javascript
const i = 20;
const j = 23;
const k = 6;
function beautifulDays(i, j, k) {
let beautifulDay = 0;
while(i<=j){ //'i' is starting day
//num to String //string to array //reverse //array to string
let a = i.toString().split('').reverse().join('');
if((i-a) % k === 0){
beautifulDay++;
}
i++;
}
console.log(beautifulDay);
}
beautifulDays(i,j,k); //2
Reference
www.hackerrank.com/challenges/beautiful-days-at-the-movies/problem