Palindrome Counter
Description:
Background
Palindromes are a special type of number (in this case a non-negative integer) that reads the same backwards as forwards. A number defined this way is called palindromic.
The following numbers are palindromes:
0
,252
,769967
,1111111
.The following numbers are not palindromes:
123
,689
,565656
,12345432
.
Problem Description
In this kata, you are required to build a function that receives two arguments, a
and b
, and returns the number of integer palindromes between a
and b
inclusive.
Examples
If
a
is6
andb
is11
, the function should output5
because there are 5 palindromes between 6 and 11 inclusive:6
,7
,8
,9
and11
.If
a
is150
andb
is250
, the function should output10
because there are 10 palindromes between 150 and 250 inclusive:151
,161
,171
,181
,191
,202
,212
,222
,232
and242
.If
a
is1002
andb
is1110
, the function should output0
: there are no palindromes between 1002 and 1110 inclusive.
Input Constraints
Fixed test cases:
0
≤a, b
≤100
(one hundred)Small test cases:
0
≤a, b
≤10^5
(one hundred thousand)Medium test cases:
0
≤a, b
≤10^10
(ten billion)Large test cases:
0
≤a, b
≤10^15
(one quadrillion)
Ideally, a program should pass all the test cases in no more than 800 milliseconds.
Edge Cases
Note that
0
is palindromic.Numbers starting with the digit
0
do not count, with the exception of 0 itself.
This is my first kata created. Hope you enjoy! <3
Similar Kata:
Stats:
Created | May 14, 2023 |
Published | May 14, 2023 |
Warriors Trained | 929 |
Total Skips | 30 |
Total Code Submissions | 2157 |
Total Times Completed | 69 |
JavaScript Completions | 25 |
Python Completions | 52 |
Total Stars | 54 |
% of votes with a positive feedback rating | 90% of 21 |
Total "Very Satisfied" Votes | 18 |
Total "Somewhat Satisfied" Votes | 2 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 8 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 5 kyu |