Jellyfish, 20 bytes
p
<
)\&&&~j<i
->N>u0
Try it online! TIO can't handle the longer test cases, but given enough time and memory, they should work too. Explanation to come later.
Explanation
i
is input, and<
decrements it. This value is fed to the function on the left.\>
increments the value (at least once) until the function to the right gives a truthy value.- The test function is a composition (by
&
s) of four functions. 0~j
converts to string.u
removes duplicate digits.>
removes the head of the resulting string.N
is logical negation: it gives1
for an empty string, and0
for non-empty. Thus the function tests for a rep-digit, and the result of\
is the next rep-digit counting from<i
.)-
subtracts the result from the function input, that is,<i
.- This difference is off by one, so
<
decrements it. Finally,p
prints the result.