Odd/even Langford/Skolem-like sequence

 

 

Hello SeqFan,

I need a little help here, please.

 

I would like to build another Langford/Skolem-like sequence which would go like this :

- every integer exactly twice in sequence ;

- between to integers T (say two 5’s) exactly T even and T odd integers (exactly 5 even and 5 odd terms between two 5’s) ;

 

Calculated by hand (with a so-so algorithm), here is what I get for the first terms :

 

1,2,3,1,6,4,2,5,7,3,8,9,12,10,4,11,13,6,5,14,15,16,17,7,18,19,20,8,23,21,9,22,26,24,10,25,27,12,11,28,29,30,31,13,32,33,36,34,14,35,37,15,40,38,16,39,41,17,42,43,44,18,.,.,19,.,.,20, etc.

 

My so-so algorithm goes like that :

 

(a) Start with « 1 » :

 

1

 

(b) Put the second « 1 », but leave the right number of « holes » between this « 1 » and the first one (between two T’s there are 2T holes -- two times the value of T) :

 

1 . . 1

 

(c) Fill the first « hole » with the smallest available integer T not leading to a contradiction so far ; when this is done, duplicate this integer T accordingly to the right (there are 4 integers between two 2’s, 6 integers between two 3’s, etc. Half of those integers must be odd and half must be even) ;

 

1 2 . 1 . . 2

 

(d) back to instruction (c)

 

Remark :

- if the last two consecutive holes are filled with integers that « neglect » a smaller one, permute those two integers (« consecutive holes » are holes not separated by an integer).

 

The sequence builds on like this, step by step :

 

1 2 . 1 . . 2

 

1 2 3 1 . . 2 . . 3

 

1 2 3 1 4 . 2 . . 3 . . . 4

 

Now, can we put 5 in the underlined hole, like this :

 

1 2 3 1 4 5 2 . . 3 . . . 4

 

No, between the two 2’s there would be three odd and one even terms -- which is not allowed.

We must put 6 instead (smallest available integer not leading to a contradiction) :

 

1 2 3 1 4 6 2 . . 3 . . . 4

 

Is it correct now ? No, not yet -- according to the Remark, we must permute 4 and 6 because we have « neglected » 5, which is smaller than 6 (last two consecutive holes rule) ; we must not forget to correct the position of the second 4 and put the second 6 :

 

1 2 3 1 6 4 2 . . 3 . . . . 4 . . 6

 

Ok, there are :

- one even and one odd integer between the two 1’s ;

- two even and two odd integers between the two 2’s.

 

The next step is easy, 5 is the smallest unused integer so far :

 

1 2 3 1 6 4 2 5 . 3 . . . . 4 . . 6 5

 

Next step requires an odd integer : 7 fits. No permutation 5<-->7 is made because no integer has been neglected ; we have now three odd and three even integers between the two 3’s :

 

1 2 3 1 6 4 2 5 7 3 . . . . 4 . . 6 5 . . . . 7

 

Next two steps use 8 and 9 :

 

1 2 3 1 6 4 2 5 7 3 8 9 . . 4 . . 6 5 . . . . 7 . . . 8 . . 9

 

We must now put two even integers in the last two consecutive holes : 10 and 12. We shall permute them because 11 has been neglected :

 

1 2 3 1 6 4 2 5 7 3 8 9 12 10 4 . . 6 5 . . . . 7 . . . 8 . . 9 . . . 10 . . 12

 

Next two steps use 11 and 13, without permutation and correctly fill the gaps between the two 6’s and 5’s :

 

1 2 3 1 6 4 2 5 7 3 8 9 12 10 4 11 13 6 5 . . . . 7 . . . 8 . . 9 . . . 10 . . 12 11 . . . . 13

 

Etc.

 

 

A note and two questions : 

 

Note : the sequence should be started with the pair 0,0. We would have thus :

0,0,1,2,3,1,6,4,2,5,7,3,8,9,12,10,4,11,13,6,5,14,15,16,17,7,18,19,20,8,23,21,9,22,26,24,10,25,27,12,11,28,29,30,31,13,32,33,36,34,14,35,37,15,40,38,16,39,41,17,42,43,44,18,.,.,19,.,.,20, etc.

 

Two questions :

1) The so-so algorithm seems to work well so far, but is it correct ?

2) I’ve tried to build another Langford/Skolem sequence like this -- using primes and non-primes instead of odd and even terms. Without success...

 

Best,

É.