# [seqfan] Re: Minimizing Q

M. F. Hasler seqfan at hasler.fr
Tue Nov 11 16:39:36 CET 2014

```Hello Eric,
The following varaitions are not in OEIS either:
0,1,3,2,5,6,7,4,9,12,11,10,13,14,15,8,17,24,19,18,21,22,23,20,25,28,27,26,29,30,31,16,33,48,35,34,37,38,39,36,41,44,43,42,45,46,47,
(the same as yours with 2 initial terms permuted ? but after 23 I find
20 and not 16 as in your OP....)
(iii) Q >=0 (not necessarily > 0)
1,0,3,4,5,2,7,10,9,8,11,12,13,6,15,22,17,16,19,20,21,18,23,26,25,24,27,28,29,14,31,46,33,32,35,36,37,34,39,42,41,40,43,44,45,38,47,
(iv) Q >= 0 and start with 0: (again the same with 2 initial terms permuted)
0,1,3,4,5,2,7,10,9,8,11,12,13,6,15,22,17,16,19,20,21,18,23,26,25,24,27,28,29,14,31,46,33,32,35,36,37,34,39,42,41,40,43,44,45,38,47

Maximilian

(PARI)
EA(n,a=1,Q=0,u=[])={for(n=1,n,print1(a",");u=setunion(u,Set(a));Q-=(-1)^a*a;forstep(k=2-Q%2,Q,2,setsearch(u,Q-k)&&next;a=Q-k;next(2));forstep(k=1,9e9,2,setsearch(u,k)&&next;
a=k;next(2)))}

On Tue, Nov 11, 2014 at 6:10 AM, Eric Angelini <Eric.Angelini at kntv.be> wrote:
>
> S=1,0,3,2,5,6,7,4,9,12,11,10,13,14,15,8,17,24,19,18,21,22,23,16,...
>
> Hello SeqFans,
>
> a(1)=1
> We now always extend S with the term
> not yet present in S that minimizes Q.
>
> Q is a quantity that must always be >0 .
> Q is set to 1 with a(1)=1 and then Q evolves:
> make Q+a(n) when the next a(n) is odd
> and make Q-a(n) when the next a(n) is even.
>
> Example:
>
> S=1,... Q=1
> S is extended with 0 as 0 minimizes Q
> at that stage (Q-0=1):
> S=1,0,... Q=1
> S is extended with 3 as we cannot
> extend it with 2 (if we do that, Q will
> be negative, which is forbidden: Q-2=-1):
> S=1,0,3,... Q=4
> S is extended with 2 as 2 is the best
> integer not yet present in S that minimizes Q:
> S=1,0,3,2,... Q=2
> S is extended with 5 as 5 is the best integer not yet present in S that minimizes Q:
> S=1,0,3,2,5,... Q=7
> S is extended with 6 as 6 is the best integer not yet present in S that minimizes Q:
> S=1,0,3,2,5,6,... Q=1
> S is extended with 7 as 7 is the best integer not yet present in S that minimizes Q:
> S=1,0,3,2,5,6,7... Q=8
> S is extended with 4 as 4 is the best integer not yet present in S that minimizes Q:
> S=1,0,3,2,5,6,7,4,,... Q=4
> S is extended with 9 as 9 is the best integer not yet present in S that minimizes Q:
> S=1,0,3,2,5,6,7,4,9,,... Q=13
> S is extended with 12 as 12 is the best integer not yet present in S that minimizes Q:
> S=1,0,3,2,5,6,7,4,9,12,,... Q=1
> Etc.
>
> S is a permutation of the integers >0.
> S seems not to be in the OEIS (nor Q).
>
> Best,
> É.
```