Consider the following series:

`0,1,2,3,4,5,6,7,8,9,10,22,11,20,13,24...`There is nothing special between numbers `0` and `10`. 

Let's start with the number `10` and derive the sequence. `10` has digits `1` and `0`. The next possible number that does not have a `1` or a `0` is `22`. All other numbers between `10` and `22` have a `1` or a `0`. 

From `22`, the next number that does not have a `2` is `11`. Note that `30` is also a possibility because it is the next *higher* number that does not have a `2`, but we must select  the *lowest* number that fits and **is not already in the sequence**. 

From `11`, the next lowest number that does not have a `1` is `20`. 

From `20`, the next lowest number that does not have a `2` or a `0` is `13`, then `24` , then `15` and so on. 

Once a number appers in the series, it cannot appear again. 

You will be given an index number and your task will be return the element at that position. See test cases for more examples.

Note that the test range is `n <= 500`. 

Good luck!

If you like this Kata, please try:

[Sequence convergence](https://www.codewars.com/kata/59971e64bfccc70748000068)

[https://www.codewars.com/kata/unique-digit-sequence-ii-optimization-problem](https://www.codewars.com/kata/unique-digit-sequence-ii-optimization-problem)

Difficulty: EASY
Starter code: def find_num(n):
	

Solutions:
masks = [0] * 10
for i in range(10 ** 4):
	for c in str(i):
		masks[int(c)] |= 1 << i

def find_num(n):
	(seq, x) = (1, 0)
	for j in range(n):
		M = seq
		for m in masks:
			if x & m:
				M |= m
		x = ~M & M + 1
		seq |= x
	return x.bit_length() - 1


M = [0]
while len(M) <= 500:
	(k, s) = (0, {c for c in str(M[-1])})
	while k in M or {c for c in str(k)} & s:
		k += 1
	M.append(k)
find_num = lambda n: M[n]


def find_num(n):
	c = 0
	k = -1
	mas = []
	while len(mas) <= n:
		k += 1
		if k > 10:
			c = set(str(mas[len(mas) - 1]))
			if len(c) == len(set(str(mas[len(mas) - 1])) - set(str(k))) and k not in mas:
				mas.append(k)
				k = 10
		else:
			mas.append(k)
	return mas[len(mas) - 1]


def find_num(n):
	seq = [0]
	i = 0
	while i < n:
		a = seq[-1]
		b = next((x for x in list(range(n * 3)) if all((y not in str(x) for y in list(str(a)))) and x not in seq))
		seq.append(b)
		i += 1
	return seq[-1]


from itertools import count

def find_num(n):
	a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20]
	while len(a) <= n:
		for i in count(11):
			if i in a:
				continue
			if not set(str(i)) & set(str(a[-1])):
				a.append(i)
				break
	return a[n]


def find_num(n):
	(found, lastComplete, lastFound) = ({0}, 0, 0)
	while len(found) <= n:
		lastDigits = set(str(lastFound))
		curr = lastComplete + 1
		while curr in found or set(str(curr)) & lastDigits:
			curr += 1
		lastFound = curr
		found.add(lastFound)
		lastComplete += lastFound == lastComplete + 1
	return lastFound


def find_num(n):
	l = [0]
	while len(l) <= n:
		m = 1
		while m in l or any([x in str(l[-1]) for x in str(m)]):
			m += 1
		l.append(m)
	return l[n]


numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 22, 11, 20, 13, 24, 15, 23, 14, 25, 16, 27, 18, 26, 17, 28, 19, 30, 12, 33, 21, 34, 29, 31, 40, 32, 41, 35, 42, 36, 44, 37, 45, 38, 46, 39, 47, 50, 43, 51, 48, 52, 49, 53, 60, 54, 61, 55, 62, 57, 63, 58, 64, 59, 66, 70, 56, 71, 65, 72, 68, 73, 69, 74, 80, 67, 81, 75, 82, 76, 83, 77, 84, 79, 85, 90, 78, 91, 86, 92, 87, 93, 88, 94, 100, 89, 101, 95, 102, 96, 103, 97, 104, 98, 105, 99, 106, 222, 107, 223, 108, 224, 109, 225, 110, 226, 111, 200, 113, 202, 114, 203, 115, 204, 116, 205, 117, 206, 118, 207, 119, 208, 131, 209, 133, 220, 134, 227, 130, 228, 135, 229, 136, 240, 137, 242, 138, 244, 139, 245, 160, 232, 140, 233, 141, 230, 144, 235, 146, 237, 145, 236, 147, 238, 149, 250, 143, 252, 148, 239, 150, 234, 151, 243, 155, 246, 153, 247, 156, 248, 157, 249, 158, 260, 154, 262, 159, 263, 170, 253, 161, 254, 163, 255, 164, 257, 166, 258, 167, 259, 168, 270, 165, 272, 169, 273, 180, 256, 171, 264, 173, 265, 174, 266, 175, 268, 177, 269, 178, 290, 176, 280, 179, 282, 190, 267, 181, 274, 183, 275, 184, 276, 185, 277, 186, 279, 188, 292, 187, 293, 400, 112, 300, 121, 303, 122, 304, 125, 306, 124, 305, 126, 307, 128, 309, 127, 308, 129, 330, 142, 333, 120, 334, 152, 336, 172, 335, 162, 337, 182, 339, 201, 338, 191, 278, 193, 284, 195, 283, 194, 285, 196, 287, 199, 286, 197, 288, 301, 289, 310, 294, 311, 295, 313, 296, 314, 297, 315, 298, 316, 299, 317, 402, 189, 302, 198, 320, 411, 322, 401, 323, 404, 123, 405, 132, 406, 192, 340, 211, 343, 210, 344, 212, 345, 216, 347, 215, 346, 217, 348, 219, 350, 214, 353, 218, 349, 221, 354, 261, 355, 241, 356, 271, 358, 291, 357, 281, 359, 407, 213, 408, 231, 409, 251, 360, 412, 363, 410, 325, 414, 326, 415, 327, 416, 328, 417, 329, 418, 332, 419, 352, 440, 312, 444, 318, 420, 319, 422, 331, 424, 351, 426, 370, 421, 365, 427, 361, 425, 366, 428, 367, 429, 368, 441, 362, 445, 321, 446, 371, 442, 369, 447, 380, 449, 372, 448, 373, 450, 376, 451, 377, 452, 378, 454, 379, 455, 381, 456, 382, 457, 383, 459, 386, 470, 385, 460, 375, 461, 387, 462, 388, 464, 389, 465, 390, 458, 391, 466, 392, 467, 393, 468, 395, 471, 396, 472, 398, 474, 399, 475, 600, 324, 500, 341, 502, 364, 501, 342, 505, 374, 506, 384, 507, 394, 508, 397, 480, 511, 403, 512, 430, 515, 423, 509, 413, 520, 431, 522, 433, 510, 432, 516, 434, 517, 436, 518, 437, 519, 438, 521, 439, 525, 443, 526, 473, 528, 463, 527, 469, 503, 476]

def find_num(n):
	return numbers[n]


(A, S, Z) = (list(range(1000)), set(), [])
while len(Z) < 501:
	for i in A:
		T = set(str(i))
		if not T & S:
			Z += [i]
			S = T
			break
	A.remove(Z[-1])
find_num = lambda n: Z[n]


from itertools import count
from functools import lru_cache
L = list(range(11))
S = set(L)

@lru_cache(maxsize=None)
def to_set(x):
	return set(str(x))

def find_num(n):
	while n >= len(L):
		x = next(filter(lambda i: not (i in S or to_set(L[-1]) & to_set(i)), count()))
		L.append(x)
		S.add(x)
	return L[n]