[seqfan] Re: Sequence like A026272 but uses 3 integers instead of 2.

Maximilian Hasler maximilian.hasler at gmail.com
Wed Jul 3 02:25:48 CEST 2013


> An implementation according to the rules:
> 1. All the natural numbers must occur exactly 3 times.
> 2. The number of terms between the 3 occurrences of the number k must be
> (k,k), (k,k+1) or (k+1,k+1)
> 3. When no previously used number is available for a new term, it is set to
> the smallest not yet used number


Consider an implementation where you place the three k's with mutual distance k
(i.e., at indices i, i+k+1, i+2k+2), as early as you can.
Then it seems that only the second place remains empty forever.

The resulting sequence starts
v = [1, 0, 1, 2, 1, 6, 2, 3, 4, 2, 5, 3, 6, 4, 8, 3, 5, 7, 4, 6, 9,
12, 5, 8, 10, 7, 11, 13, 14, 15, 9, 16, 8, 7, 12, 10, 17, 18, 11, 19,
9, 13, 20, 14, 21, 15, 10, 12, 16, 27, 11, 22, 23, 24, 17, 13, 18, 25,
14, 19, 26, 15, 28, 20, 29, 16, 21, 30, 33, 31, 35, 32, 17, 34, 22,
18, 23, 27, 24, 19, 36, 37, 38, 25, 20, 39, 40, 26, 21, 41, 53, 28,
42, 46, 29, 43, 44, 22, 30, 45, 23, 31, 33, 24, 32, 27, 35, 47, 34,
25, 48, 49, 50, 56, 26, 51, 52, 36, 55, 37, 28, 38, 54, 57, 29, 39,
58, 40, 59, 30, 64, 41, 60, 31, 61, 42, 33, 32, 62, 43, 46, 44, 35,
34, 53, 45, 63, 65, 66, 67, 70, 68, 71, 69, 36, 47, 72, 37, 74, 48,
38, 49, 73, 50, 75, 39, 76, 51, 40, 52, 56, 77, 78, 41, 55, 79, 80,
54, 42, 81, 82, 57, 83, 43, 84, 58, 44, 46, 59, 85, 86, 45, 87, 60,
88, 64, 61, 89, 53, 90, 99, 62, 91, 47, 92, 93, 94, 95, 48, 96, 63,
49, 98, 65, 50, 66, 97, 67, 100, 51, 68, 70, 52, 69, 71, 103, 101, 56,
102, 72, 55, 104, 54, 74, 105, 106, 73, 107, 108, 57, 75, 109, 110,
76, 58, 111, 112, 114, 59, 77, 116, 78, 113, 115, 60, 79, 117, 80, 61,
118, 64, 81, ...]

The minimal length of the vector required to place all numbers up to k is:
m = (5,10,16,19,23,34,41,47,51,56,59,62,66,73,76,80,85,89,98,101,104,110,115,121,125,130,134,138,144,155,158,161,166,169,174,179,184,187,
192,204,209,212,215,220,223,233,240,245,249,255,259,265,275,280,283,286,290,294,297,303,311,317,321,328,331,336,339,344,347,351,355,
362,365,369,373,378,382,387,391,394,397,400,404,413,421,431,435,442,447,450,454,457,462,465,470,473,481,486,493,498,503,510,515,518,
523,529,533,543,549,556,564,575,582,588,593,596,600,607,612,618,622,625,635,640,643,650,657,667,673,681,685,691,698,705,708,714,719,...)

Since the third k is at index i+2k+2, this allows also to know that
the first k is placed at index i(k) = m(k)-2k-2 (if the places are
numbered starting at i=1).
i=(1,4,8,9,11,6,18,15,21,25,27,22,28,29,30,32,37,38,40,43,45,52,53,54,58,61,50,63,65,68,70,72,69,74,71,81,82,83,86,87,90,93,96,97,100,94,108,111,112,113,116,117,91,123,119,114,124,127,129,133,135,139,147,131,148,149,150,152,154,151,153,157,163,159,165,167,172,173,176,177,180,181,183,185,190,191,193,195,198,200,203,205,206,207,208,210,217,213,201,219,227,229,226,232,235,236,238,239,242,243,246,247,253,248,254,251,257,260,...)

Obviously, the ugly thing is the ever-lasting v[2]=0...

Maximilian

PS: for my records
lb= n->v=vector(n);for(i=1,#v,for(j=1,#v-i*2-2,v[j]+v[j+i+1]+v[j+i*2+2]&next;v[j]=v[j+i+1]=v[j+i*2+2]=i;next(2));return([i,v]))

m=1;for(i=1,999,m+0<(m=lb(i)[1])&print1(i",")) \\ seq."m"

v->for(i=1,vecmax(v),for(j=1,#v,v[j]==i & !print1(j",") & next(2));error)



More information about the SeqFan mailing list