OFFSET
1,2
COMMENTS
In contrast to A277858, any one or more digits of a(n) can be omitted. (For example, if a(n) = 123, the absolute difference may be any of { 1, 2, 3, 12, 13, 23, 123 }, while 13 would be forbidden in A277858.)
To ensure the sequence is infinite, one has to check whether a potential successor of a term will have a successor itself. For example, a(80) = 51 would most naively be followed by 51 - 5 = 46, which does not occur earlier, but which then would have no possible successor. Therefore one must choose a(81) = 51 + 51 = 102.
This sequence differs from A277858 from a(88) = 120 on (which follows a(87) = 138 = a(88) + 18), while a gap of 18 is not allowed at this point in A277858, where A277858(88) = 125 = a(87) - 13. Thereafter this sequence continues completely differently from A277858, but they have the same set of 12 numbers {3, 5, 6, 7, 11, 12, 13, 14, 15, 33, 46, 61} which never appear.
It is easy to prove that this is not a permutation of the positive integers: indeed, for example, the number 5 can never occur in the sequel, since it has no possible successor (10 being already used). There are several variants of this sequence, some of which are permutations: Aside the stronger condition defining A277858, one could consider the weaker conditions "digits of |a(n+1)-a(n)| are a sub-multiset of those of a(n)" (e.g., a step of 21 would be allowed after 123), or "... are a subset of ..." (a step of 11 would be allowed after 123). The latter variant (which is a permutation) is A276070.
PROG
(PARI) /* 'a' subsequence of 'b'?*/ ss(a, b, i=1, k=1)={while(k < #b && #b-k >= #a-i, b[k] == a[i] && (i==#a || ss(a, b, i+1, k+1)) && return(1); k++); k==#b && i==#a && b[k] == a[i]}
A(n, a=1, g=1)={u=[]; for(n=2, n, g&&print1(a", "); u=setunion(u, [a]); /*while(#u>2&&u[2]==u[1]+1, u=u[^1]); */ d=digits(a); for(k=u[1]+1, 2*a, (!setsearch(u, k)&&ss(digits(abs(a-k)), d))||next; p==a&&u=setminus(u, [b]); [p, a]=[a, k]; next(2)); g&&print1(" er, no: delete "a", go back to "); b=a; a=p); a} \\ Implementation of backtracking should be improved
CROSSREFS
KEYWORD
nonn,base
AUTHOR
M. F. Hasler, Nov 05 2016
STATUS
approved