OFFSET
1,3
COMMENTS
This is very similar to A033075, with the exception of considering 0 and 9 as adjacent digits. This allows these digits to be equal to the other digits, making it a more balanced list.
MAPLE
q:= n-> (l-> andmap(x-> x in {1, 9}, {seq(abs(l[i]-l[i-1]),
i=2..nops(l))}))(convert(n, base, 10)):
select(q, [$0..1000])[]; # Alois P. Heinz, Sep 14 2022
MATHEMATICA
q[n_] := AllTrue[Abs @ Differences @ IntegerDigits[n], MemberQ[{1, 9}, #] &]; Select[Range[0, 1000], q] (* Amiram Eldar, Sep 15 2022 *)
PROG
(Python)
def add_dig(x):
d = (x%10-1)%8 if x%10 != 0 else 1
return 10*x+d
def try_incr(x):
if x < 10: return x+1
r = x//10
d2 = r%10
d = max((d2+1)%10, (d2-1)%10)
return 10*r+d
def incr(x):
new_x=try_incr(x)
return new_x if new_x>x else add_dig(incr(x//10))
x = 0
for n in range(1, 1000):
print(f"{n} {x}")
x = incr(x)
(PARI) a(n) = { n--; for (b=0, oo, if (n <= 9*2^b, my (v=ceil(n/2^b), p=(n-1)%(2^b)); while (b>0, v=10*v+vecsort([(v-1)%10, (v+1)%10])[1+bittest(p, b--)]; ); return (v), n -= 9*2^b)) } \\ Rémy Sigrist, Sep 15 2022
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Ofer Zivony, Sep 14 2022
STATUS
approved