Consider the numbers `6969` and `9116`. When you rotate them `180 degrees` (upside down), these numbers remain the same. To clarify, if we write them down on a paper and turn the paper upside down, the numbers will be the same. Try it and see! Some numbers such as `2` or `5` don't yield numbers when rotated.

Given a range, return the count of upside down numbers within that range.  For example, `solve(0,10) = 3`, because there are only `3` upside down numbers `>= 0 and < 10`. They are `0, 1, 8`.

More examples in the test cases.

Good luck!

If you like this Kata, please try 

[Simple Prime Streaming](https://www.codewars.com/kata/5a908da30025e995880000e3)

[Life without primes](https://www.codewars.com/kata/59f8750ac374cba8f0000033)

Please also try the performance version of this kata at [Upside down numbers - Challenge Edition ](https://www.codewars.com/kata/59f98052120be4abfa000304)

Difficulty: EASY
Starter code: def solve(a, b):
	

Solutions:
REV = {'6': '9', '9': '6'}
BASE = set('01869')

def isReversible(n):
	s = str(n)
	return not set(s) - BASE and (not len(s) % 2 or s[len(s) // 2] not in '69') and all((REV.get(c, c) == s[-1 - i] for (i, c) in enumerate(s[:len(s) // 2])))

def solve(a, b):
	return sum((isReversible(n) for n in range(a, b)))


def solve(a, b):
	return sum((str(n) == str(n)[::-1].translate(str.maketrans('2345679', 'XXXX9X6')) for n in range(a, b)))


def solve(a, b):
	tr = str.maketrans('0123456789', '01----9-86')
	return sum((1 for x in map(str, range(a, b)) if x == ''.join(reversed(x.translate(tr)))))


solve = lambda a, b: sum((n == n.translate(n.maketrans('2345679', '----9-6'))[::-1] for n in map(str, range(a, b))))


table = str.maketrans('69', '96', '23457')

def solve(a, b):
	return sum((1 for n in range(a, b) if f'{n}'[::-1] == f'{n}'.translate(table)))


def solve(a, b):
	s = {'0', '1', '6', '8', '9'}
	total = 0
	for i in range(a, b):
		if i < 10:
			if i in (0, 1, 8):
				total += 1
		else:
			n = str(i)
			if set(n).issubset(s):
				(left, right) = (0, len(n) - 1)
				while left <= right:
					ln = n[left]
					rn = n[right]
					if left == right and ln in '69':
						break
					if ln + rn in ('69', '96') or (ln == rn and ln in '018'):
						left += 1
						right -= 1
					else:
						break
				if left > right:
					total += 1
			else:
				continue
	return total


rot = dict(['00', '11', '88', '69', '96'])

def upside_down_number(n):
	s = str(n)
	return s == ''.join((rot.get(c, '') for c in reversed(s)))

def solve(a, b):
	return sum((upside_down_number(i) for i in range(a, b)))


def solve(a, b):
	return sum((all((a + b in '69 96 88 11 00' for (a, b) in zip(str(i), str(i)[::-1]))) for i in range(a, b)))


dictio = {'0': '0', '1': '1', '6': '9', '9': '6', '8': '8'}

def solve(a, b):
	return sum((1 for i in range(a, b) if transf(i)))

def transf(n):
	n = str(n)
	for (i, j) in enumerate(n):
		if j not in dictio:
			return False
		elif dictio[j] != n[-i - 1]:
			return False
	return True


def solve(a, b):
	count = 0
	for num in range(a, b):
		num = str(num)
		if num == num.translate(str.maketrans('1234567890', '1xxxx9x860'))[::-1]:
			count += 1
	return count