Title is made up, from 'Sequence Index Digit Not'.
##Challenge:
Given an integer n which is >= 0, output the n'th number of the following sequence.
Here are the first 50 items, with it's (0-indexed) index above it:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1 0 3 2 5 4 7 6 9 8 22 20 30 24 23 26 25 28 27 32 11 33 10 14 13 16 15 18 17 31 12 29 19 21 50 40 41 42 44 45 35 36 37 51 38 39 52 53 55 56 34 ##How does this sequence work?
The number at index n must be the first in order that does not have any digits in common with n, and hasn't occurred yet for previous indexes. So when we look at normal sequence like this from 0-60:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 We define the n'th values like this:
0: The first number (0) contains the same digit, so we look for the next (1), which does not contain the same digit. Son=0outputs1.1: The first number (0) does not contain the same digit, son=1outputs0.2: We've already encountered0and1, and the next digit (2) contains the same digit, so we look for the next (3), which does not contain the same digit. Son=2outputs3.- ...
10: We've already encountered0-9, so the next in line is10.10-19contain the matching digit1,20contains the matching digit0,21contains the matching digit1again,22is valid, son=10outputs22.- etc.
##Challenge rules:
- If your language is 1-indexed (or you choose to) you are allowed to start the sequence at
3 2 5 4 7 ...(skipping the1atn=0and the0atn=1). - The minimum largest index you should support is
25,000. NOTE: The sequence stops at index1,023,456,788, because the next index in line contains all 10 digits. - You are also allowed to output / return an array/list of the entire sequence up to and including index
nif you want to.
##General rules:
- This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language. - Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
- Default Loopholes are forbidden.
- If possible, please add a link with a test for your code.
- Also, please add an explanation if necessary.
##Test cases:
This sequence actually created pairs regarding index and outputs. If index n outputs o, index o outputs n. So you can input either the left or right, and the output will be the other side:
0 <-> 1 (this test case is optional) 2 <-> 3 10 <-> 22 12 <-> 30 34 <-> 50 89 <-> 100 111 <-> 200 112 <-> 300 199 <-> 322 2231 <-> 4456 9605 <-> 11118 19235 <-> 46000 23451 <-> 60668 25000 <-> 13674 Here is a pastebin of the first 25,001 test cases if you want to try others.