Problem:
Score : 200 points

Problem Statement

Find the number of palindromic numbers among the integers between A and B (inclusive).
Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.

Constraints

10000 \leq A \leq B \leq 99999

All input values are integers.

Input

Input is given from Standard Input in the following format:

A B

Output

Print the number of palindromic numbers among the integers between A and B (inclusive).

Sample Input 1

11009 11332

Sample Output 1

4

There are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.

Sample Input 2

31415 92653

Sample Output 2

612

Solution in Rust (1.42.0) (judge verdict: Accepted)

use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn digit_count(n: u64) -> u64 {
    if n == 0 {
        return 1;
    }
    for i in 0..20u32 {
        if n < 10u64.pow(i) {
            return i as u64;
        }
    }
    20u64
}

fn digits(n: u64) -> Vec<u64> {
    let mut m = n;
    let mut vec: Vec<u64> = Vec::new();
    let mut i = digit_count(m) as u32 - 1;
    loop {
        let l = m / 10u64.pow(i);
        vec.push(l);
        m -= l * 10u64.pow(i);
        if i == 0 {
            break;
        }
        i -= 1;
    }
    vec
}

fn main() {
    let (a, b) = input_tuple();
    let mut count = 0;
    for i in a..(b+1) {
        let d = digits(i);
        let mut flag = true;
        let n = digit_count(i) as usize;
        for i in 0..n/2 {
            if d[i] != d[n - i - 1] {
                flag = false;
            }
        }
        if flag {
            count += 1;
        }
    }
    println!("{}", count);
}