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 Go (1.6) (judge verdict: Accepted)

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

const debug = false

func (p *problem) solve() {
	var count int
	in := p.nextSSLine()
	a, b := stoi(in[0]), stoi(in[1])
	log.Printf("%v->%v", rank(in[0], 0), rank(in[1], 0))
	for i := rank(in[0], 0); i <= rank(in[1], 0); i++ {
		for j := 0; j <= 9; j++ {
			for k := 0; k <= 9; k++ {
				n := stoi(fmt.Sprintf("%d%d%d%d%d", i, j, k, j, i))
				log.Printf("n: %d", n)
				if between(n, a, b) {
					count++
				}
			}
		}
	}
	p.printf("%d", count)
}

func between(x, a, b int) bool {
	ok := a <= x && x <= b
	log.Printf("a(%v) <= x(%v) <= b(%v) = %v", a, x, b, ok)
	return ok
}

func rank(s string, i int) int {
	return stoi(string([]rune(s)[i]))
}

func main() {
	if debug {
		log.SetOutput(os.Stdout)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) printi(d int) {
	if err := p.out.WriteByte(byte(d)); err != nil {
		panic(err)
	}
}

func (p *problem) printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) nextInt() int {
	return stoi(p.next())
}

func (p *problem) nextInts() []int {
	line := p.nextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) nextSSLine() []string {
	return strings.Split(p.next(), " ")
}

// Next reads line and return string.
func (p *problem) next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}