An eviternity number is a number which:
* contains only digits 8, 5 and 3, and 
* the count of the digit `8` >= count of digit `5` >= count of digit `3`. 

The first few eviternity numbers are as follows. 
```Haskell
[8, 58, 85, 88, 358, 385, 538, 583, 588, 835, 853, 858, 885, 888]
```
You will be given two integers, `a` and `b`, and your task is to return the number of eviternity numbers in the range `>= a and < b`.
```Haskell
For example:
solve(0,1000) = 14, because they are [8, 58, 85, 88, 358, 385, 538, 583, 588, 835, 853, 858, 885, 888]
```

The upper bound will not exceed `500,000`.

More examples in test cases. Good luck!

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def solve(a, b):
	

Solutions:
u = [8, 58, 85, 88, 358, 385, 538, 583, 588, 835, 853, 858, 885, 888, 3588, 3858, 3885, 5388, 5588, 5838, 5858, 5883, 5885, 5888, 8358, 8385, 8538, 8558, 8583, 8585, 8588, 8835, 8853, 8855, 8858, 8885, 8888, 35588, 35858, 35885, 35888, 38558, 38585, 38588, 38855, 38858, 38885, 53588, 53858, 53885, 53888, 55388, 55838, 55883, 55888, 58358, 58385, 58388, 58538, 58583, 58588, 58835, 58838, 58853, 58858, 58883, 58885, 58888, 83558, 83585, 83588, 83855, 83858, 83885, 85358, 85385, 85388, 85538, 85583, 85588, 85835, 85838, 85853, 85858, 85883, 85885, 85888, 88355, 88358, 88385, 88535, 88538, 88553, 88558, 88583, 88585, 88588, 88835, 88853, 88855, 88858, 88885, 88888, 335588, 335858, 335885, 338558, 338585, 338855, 353588, 353858, 353885, 355388, 355838, 355883, 355888, 358358, 358385, 358538, 358583, 358588, 358835, 358853, 358858, 358885, 358888, 383558, 383585, 383855, 385358, 385385, 385538, 385583, 385588, 385835, 385853, 385858, 385885, 385888, 388355, 388535, 388553, 388558, 388585, 388588, 388855, 388858, 388885]

def solve(a, b):
	return sum((a <= x < b for x in u))


eviternity = [int(n) for n in map(str, range(10 ** 6)) if set(n) <= set('358') and n.count('3') <= n.count('5') <= n.count('8')]
solve = lambda a, b, f=__import__('bisect').bisect_left: f(eviternity, b) - f(eviternity, a)


def ever(n):
	s = str(n)
	C = [s.count('3'), s.count('5'), s.count('8')]
	if sum(C) == len(s) and sorted(C) == C:
		return True
	return False
D = {i for i in range(1000000) if ever(i)}

def solve(a, b):
	return len({e for e in D if e >= a and e <= b})


import itertools

def merge(l):
	return ''.join(l)

def solve(a, b):
	digits = ['3', '5', '8', '']
	c2 = set(map(merge, itertools.product(digits, digits, digits, digits, digits, digits)))
	c2.remove('')
	c = 0
	for n in c2:
		if int(n) >= a and int(n) < b:
			if n.count('8') >= n.count('5') and n.count('5') >= n.count('3'):
				c += 1
	return c


from collections import Counter
from itertools import product

def valid(s):
	c = Counter(s)
	return c[8] >= c[5] >= c[3]
ALL = [int(''.join(map(str, digs))) for nd in range(1, 7) for digs in product((3, 5, 8), repeat=nd) if valid(digs)]

def solve(a, b):
	return sum((a <= n < b for n in ALL))


from itertools import product

def solve(a, b):
	(res, start, stop) = ([], len(str(a)), len(str(b)) + 1)
	for i in range(start, stop):
		res += [''.join(x) for x in product('538', repeat=i)]
	return sum((1 for x in res if a <= int(x) <= b and x.count('8') >= x.count('5') >= x.count('3')))


from itertools import permutations
EVI = {8, 58, 85, 88, 358, 385, 538, 583, 588, 835, 853, 858, 885, 888, 8888, 88888, 888888, 8888888}
for n in [8885, 8855, 8853, 88885, 88855, 88853, 88553, 888885, 888855, 888853, 888555, 888553, 885533]:
	for perm in permutations(str(n)):
		EVI.add(int(''.join(perm)))

def solve(a, b):
	return sum((a <= n < b for n in EVI))


from re import match
memo = {}

def solve(a, b):
	return sum((1 for n in range(a, b) if is_eviternity(n)))

def is_eviternity(n):
	if n not in memo:
		s = str(n)
		memo[n] = match('[853]+$', s) and s.count('8') >= s.count('5') >= s.count('3')
	return memo[n]


from functools import lru_cache

@lru_cache(maxsize=None)
def f_checker(num):
	if all([i in ['3', '5', '8'] for i in str(num)]):
		count_8 = str(num).count('8')
		count_5 = str(num).count('5')
		count_3 = str(num).count('3')
		if count_8 >= count_5 and count_5 >= count_3:
			return num

def solve(a, b):
	counter = 0
	for num in range(a, b):
		res = f_checker(num)
		if res:
			counter += 1
	return counter


def solve(a, b):
	number_counter = 0
	for i in range(a, b):
		number = str(i)
		if '0' in number or '1' in number or '2' in number or ('4' in number) or ('6' in number) or ('7' in number) or ('9' in number):
			continue
		a = number.count('3')
		b = number.count('5')
		c = number.count('8')
		if a + b + c == len(number) and a <= b and (b <= c):
			number_counter += 1
	return number_counter