ID generator with no matching contiguous pairs
Brachylog, 11 10 bytes
{≤ṫẹ~ḅẉ}ᶠ⁾
Input is a list of two numbers. Try it online!
Explanation
The built-in ḅ
takes a list or string, like "1000220"
, and splits it into blocks of equal adjacent elements, like ["1","000","22","0"]
.
In this program, I apply the ~
operator to it, so it works in reverse: it takes a list of strings, checks that each string consists of repetitions of a single character and neighboring strings have different characters, and concatenates the list.
The predicate ≤
enumerates numbers starting from the first input in increasing order, and I check a condition on them, printing those that satisfy it and stopping when I've found enough.
{≤ṫẹ~ḅẉ}ᶠ⁾ Input is a pair, say [M=988,N=3].
{ }ᶠ⁾ Apply this predicate to M and compute the first N results.
≤ Take a number that is greater than or equal to M (first up is 988).
ṫ Convert it to string: "988"
ẹ Split it into substrings of length 1: ["9","8","8"]
~ḅ Apply ḅ in reverse: fails, try next number.
ẉ If ḅ succeeds, print the resulting string and a newline.
This counts as a result of the predicate.
05AB1E, 9 bytes
µÐÔQi=¼}>
Try it online!
Exlpanation
µ # loop until counter equals n
Ð # triplicate current value (initially m)
Ô # connected uniqueified on the copy at the top of the stack
Q # compare to unmodified for equality
i } # if true
= # print current value while leaving it on the stack
¼ # increment the counter
> # increment current value
Java 8, 83 bytes
(m,n)->{for(;n>0;m++)if(!(m+"").matches(".*(.)\\1.*")){System.out.println(m);n--;}}
Explanation:
Try it online.
(m,n)->{ // Method with two integer parameters and no return-type
for(;n>0; // Loop as long as `n` is larger than 0
m++) // After every iteration: increase `m` by 1
if(!(m+"").matches(".*(.)\\1.*")){
// If there are no repeated adjacent digits:
System.out.println(m); // Print `m`
n--;}} // And decrease `n` by 1