You are viewing a single comment's thread. Return to all comments →
Looking at other solutions makes me want to cry, because this is what I had to do in C
int reverseNumber(int number) { int digits = 0, divisor = 1; for (; divisor < number; divisor *= 10){ digits++; } divisor /= 10; int inverted = 0, multiplier = 1; for (; digits > 0; digits--) { inverted += (number/divisor) * multiplier; number -= (number/divisor) * divisor; divisor /= 10; multiplier *= 10; } return inverted; } int beautifulDays(int i, int j, int k) { int days = 0, day; for (int z = 0; z < j-i+1; z++){ day = i + z; if((day - reverseNumber(day)) % k == 0) days++; } return days; }
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 →
Looking at other solutions makes me want to cry, because this is what I had to do in C