login
A277845
The digits of the absolute difference |a(n+1)-a(n)| are a subsequence of the digits of a(n): Lexicographically first infinite sequence with this property and without negative or repeated terms.
1
1, 2, 4, 8, 16, 10, 9, 18, 17, 24, 20, 22, 44, 40, 36, 30, 27, 25, 23, 21, 19, 28, 26, 32, 29, 31, 34, 37, 74, 67, 60, 54, 49, 45, 41, 42, 38, 35, 70, 63, 57, 50, 55, 110, 99, 90, 81, 73, 66, 72, 65, 59, 64, 58, 53, 48, 52, 47, 43, 39, 78, 71, 142, 100, 101, 91, 82, 80, 88, 96, 87, 79, 86, 92, 83, 75, 68, 62, 56
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
Sequence in context: A009289 A070335 A277846 * A277858 A366031 A167421
KEYWORD
nonn,base
AUTHOR
M. F. Hasler, Nov 05 2016
STATUS
approved