# [seqfan] Re: seqs whose |differences| are 1,2,3,4,...

Robert G. Wilson v rgwv at rgwv.com
Tue Mar 9 21:44:56 CET 2010

```Dear Paul Raff,

Will you be submitting the sequence:
{1, 2, 4, 7, 3, 8, 14, 21, 13, 22, 12, 23, 11, 24, 10, 25, 9, 26, 44, 63,
43, 64, 42, 65, 41, 66, 40, 67, 39, 68, 38, 69, 37, 70, 36, 71, 35, 72, 34,
73, 33, 74, 32, 75, 31, 76, 30, 77, 29, 78, 28, 79, 27, 80, 134, 189, 133,
190, 132, 191, 131, 192, 130, 193, 129, 194, 128, 195, 127, 196, 126, 197,
125, 198, 124, 199, 123, 200, 122, 201, 121, 202, 120, 203, 119, 204, 118,
205, 117, 206, 116, 207, 115, 208, 114, 209, 113, 210, 112, 211}
which is the result of: GenerateSequence[{1}, 100, True]
This sequence is different from
http://www.research.att.com/~njas/sequences/A063733 beginning at a(24); as
noted by others.

Or the results of any other combination or starting points?

Sincerely yours, Bob.

--------------------------------------------------
From: "Raff, Paul" <praff at math.rutgers.edu>
Sent: Tuesday, March 09, 2010 12:19 PM
To: "Sequence Fanatics Discussion list" <seqfan at list.seqfan.eu>
Cc: <seqfan at seqfan.eu>; <njas at research.att.com>
Subject: [seqfan] Re: seqs whose |differences| are 1,2,3,4,...

> Very interesting sequence. It seems that we can follow this heuristic
> with backtracking:
>
> 1. If we've just added to our list, currently of length n, then we
> first try to add LAST-n to the list if possible, otherwise we add
> LAST+n, where LAST is the last element of the list.
> 2. If we're backtracking at the moment, then we know we have already
> tried to add LAST-n, so we add LAST+n. If we can't, then we stop and
> fail.
>
> The following Mathematica code appears to do it:
>
> GenerateSequence[{}, _, _] := {}
> GenerateSequence[L_List, max_Integer, True] :=
> If[Length[L] == max, L,
>  With[{n = Length[L]},
>   If[Last[L] - n < 1 || MemberQ[L, Last[L] - n],
>    If[MemberQ[L, Last[L] + n],
>     GenerateSequence[Drop[L, -1], max, False],
>     GenerateSequence[Append[L, Last[L] + n], max, True]],
>    GenerateSequence[Append[L, Last[L] - n], max, True]]]]
> GenerateSequence[L_List, max_Integer, False] :=
> With[{n = Length[L]},
>  If[MemberQ[L, Last[L] + n],
>   GenerateSequence[Drop[L, -1], max, False],
>   GenerateSequence[Append[L, Last[L] + n], max, True]]]
>
> Start if off with GenerateSequence[{1},N,True], where N is the length
> of the list when you want it to stop. When looking at this sequence a,
> if there is an index n such that a_n < a_{n+1} then the sequence won't
> change any more for the first n+1 terms.
>
> However - based on its progression, it won't be a permutation of the
> natural numbers.
>
>
>                                                 [paul]
>
> ---
> Paul Raff
> Postdoctoral Researcher - Cognitive Assistants as Analysts' Deputies
> School of Communication and Information
> Rutgers University
> http://www.myraff.com
> Work: (732) 932-7500 x8023
> Mobile: (704) 604-2154
> ---
>
>
>
> On Tue, Mar 9, 2010 at 11:39 AM, N. J. A. Sloane <njas at research.att.com>
> wrote:
>>
>> Dear Seqfans,
>>
>> Consider all rearrangements of the natural numbers with the property that
>> the absolute values of the differences are 1,2,3,4,5,... (in that order).
>>
>> John Conway asks, what is the lexicographically earliest such sequence?
>>
>> The greedy approach leads you to A078943, which dies after 24 terms.
>>
>> Recaman's sequence A005132 (or rather, the version defined
>> on the positive integers, A063733) is another failure, because it
>> contains
>> repeated terms.
>>
>> Does anyone have a candidate for the answer?
>>
>> Neil
>>
>>
>>
>> _______________________________________________
>>
>> Seqfan Mailing list - http://list.seqfan.eu/
>>
>
>
> _______________________________________________
>
> Seqfan Mailing list - http://list.seqfan.eu/

```