%I #38 May 13 2019 12:28:07
%S 1,2,5,3,7,10,4,6,12,15,17,8,20,9,22,11,25,27,29,14,13,33,35,37,16,40,
%T 18,19,42,45,47,49,21,24,52,55,23,58,61,62,30,26,65,66,28,68,34,31,71,
%U 74,76,79,81,39,32,83,86,36,89,43,38,91,93,96,99,41,101,50,103,106,44,108,54,111,46,113,117,48,57,118,51,120,123
%N Start at n=1. Fill in a(n) with a value d > 0 not used earlier such that n-d or n+d is the smallest possible index not visited earlier, then continue with that index.
%C A variant of Recamán's sequence: start at n=1, a(1)=1, then iterate: let n' = n - a(n) if this n' > 0 and was not visited earlier, otherwise n' = n + a(n). Then let n'' <> n' be the smallest index not visited earlier (a(n'') not yet defined) such that the value |n'-n''| was not yet used (meaning not yet a value of any a(i)). Set a(n') = |n'-n''| and continue with n = n'. [Name and Comment suggested by _M. F. Hasler_ at the request of the authors.]
%C Conjectured to be a permutation of the positive integers. The conjectured inverse permutation is given in A308049. - _M. F. Hasler_, May 10 2019
%C Comment from _Rémy Sigrist_ and _N. J. A. Sloane_, May 13 2019 (Start):
%C The sequence is given by the following formula. Let R(t) = A081145(t). Then for all t >= 1, a(R(t)) = |R(t+1)-R(t)|.
%C For example, for t=10, R(10)=20, R(11)=6, and a(R(10)) = a(20) = |6-20| = 14.
%C Since it is known that {R(t): t>=1} is a permutation of the positive integers (it is the "Slater-Velez permutation of the first kind"), this specifies a(n) for all n.
%C The connection with the definition as interpreted above by _M. F. Hasler_ is that at step t of the procedure, n' is R(t) = A081145(t), n'' is R(t+1) = A081145(t+1), and we calculate a(R(t)) = |n'-n''| = |R(t)-R(t+1)|.
%C The conjecture that {a(n)} is a permutation of the positive integers is equivalent to Slater and Velez's conjecture (see references) that the absolute values of the first differences of A081145 are also a permutation of the positive integers. This problem appears to be still unsolved. (End)
%D P. J. Slater and W. Y. Velez, Permutations of the Positive Integers with Restrictions on the Sequence of Differences, II, Pacific Journal of Mathematics, Vol. 82, No. 2, 1979, 527-531.
%H Jean-Marc Falcoz, <a href="/A308021/b308021.txt">Table of n, a(n) for n = 1..5564</a>
%H P. J. Slater and W. Y. Velez, <a href="http://projecteuclid.org/euclid.pjm/1102811644">Permutations of the Positive Integers with Restrictions on the Sequence of Differences</a>, Pacific Journal of Mathematics, Vol. 71, No. 1, 1977, 193-196.
%H William Y. Velez, <a href="https://doi.org/10.1016/0012-365X(92)90724-T">Research problems 159-160</a>, Discrete Math., 110 (1992), pp. 301-302.
%e a(1) = 1 drives us to the empty cell a(2) since we can't go further to the left. We fill this cell with the number 2 which is the smallest integer not used before and thus allows us to go to the leftmost possible empty cell, 2 + 2 = 4. (There are no empty places to the left and we can't go to 3 = 2 + 1 since a step 1 has already been used.) So we have a(2) = 2.
%e a(2) = 2 drives us to the empty cell a(4). We see that the leftmost empty cell a(3) cannot be reached from a(4) since a step of 1 has already been used. We thus fill the cell a(4) with the smallest integer not used before, a(4) = 3.
%e a(4) = 3 drives us to the empty cell a(7). We see that the leftmost empty cell a(3) can now be reached from a(7) if we fill a(7) with 4; we have thus a(7) = 4.
%e a(7) = 4 drives us to the empty cell a(3), which is the one we wanted to fill. We fill a(3) with 5 which is the smallest integer not leading to a contradiction, whence a(3) = 5.
%e a(3) = 5 drives us to the empty cell a(8). We would like to fill this cell with 3, as this 3 would allow us to fill the leftmost empty cell of the sequence - but 3 has been used before; thus we'll have a(8) = 6.
%e a(8) = 6 drives us to the empty cell a(14). We fill a(14) with 9 as this will allow us to reach the leftmost empty cell of the sequence, whence a(14) = 9.
%e a(14) = 9 drives us to the empty cell a(5). We fill a(5) with 7 as this is the smallest integer not leading to a contradiction, so we have a(5) = 7, etc.
%o (PARI) {A=vector(N=199); n=1; while (n<=N,S=Set(A); Z=select(t->!t,A,1); for (i=1,#Z,Z[i]!=n||next; setsearch(S, abs(n-z=Z[i]))&& next; A[n]=abs(n-z); n=z; next(2)); break); if(#Z, A[1..Z[1]-!A[Z[1]]], A)} \\ _M. F. Hasler_, May 09 2019
%Y Cf. A005132 (Recamán's sequence), A171884 (injective variant).
%Y Cf. A308049 (conjectured inverse permutation).
%Y See also A081145, A081146, A099004.
%K base,nonn
%O 1,2
%A _Eric Angelini_ and _Jean-Marc Falcoz_, May 09 2019