New Results and Algorithms

distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. Abstract This paper presents new characterizations and algorithmic results for generalized Skolem and Langford sequences with minimum number of zeros. It generalize the necessary conditions for existence and locations for each zero of generalized Langford sequences. New algorithm implementations are used to find new sequences and analyze the space of solutions for a range of cases. Expanded tables of computational results are given, along with several efficient probabilistic ways of finding solutions in very large search cases.


Introduction
There is increasing interest among mathematicians and computer scientists in finding new algorithms as well as new computational results for the existence of Langford and generalized Langford sequences.For example, solving the Langford problem in parallel [6], and the Langford problem as a challenge for parallel resolution of CSP [5].A large number of computer scientists are referenced on the website of J.E. Miller, developing new algorithms and finding new solutions for the Langford problem [9].
The concept of a Skolem sequence was introduced almost simultaneously as that of a Langford sequence, both papers were published in 1957, although posed using different tools and terminology, they are indeed very similar.
In 1957, Thoralf Skolem , motivated by a study of Steiner Triple Systems (STS), asked the question: is it possible to distribute the numbers 1, 2, . . ., 2n in pairs (a r , b r ), such that b r − a r = r for every r = 1, 2, . . ., n? [23] For example, it is possible to distribute, or partition, the numbers {1, 2, . . .8} into the pairs (1, 2), (4,6), (5,8), (3,7) where 2 − 1 = 1, 6 − 4 = 2, 8 − 5 = 3, and 7−3 = 4. Skolem was able to show proofs of sufficient and necessary conditions for the existence of these partitions.The form of these partitions defined by Skolem can be represented as a sequence of integers 2n from 1, 2, . . ., n .This is called a Skolem sequence and was introduced in 1966 [10].In this sequence each element k occurs exactly twice, and is separated by k positions.For example, the partition given above can be equivalently represented in this notation as (1,1,4,2,3,2,4,3) and is 2 of the 6 Skolem sequences of order n = 4, counting it's reverse as a distinct sequence.In 1958, using the results from his 1957 paper [23], Skolem showed that the existence of a ST S(6n + 1) is given by the existence of a Skolem sequence of order n.He used a transformation from the Skolem sequence to the base blocks of the ST S(6n + 1) [24].
In 1958, Skolem was the first to consider what is now called a hooked Skolem sequence, where there exists a zero, or hook, at the second to last position of the sequence containing 2n + 1 elements [24].O'Keefe, in 1961, proved necessary conditions for their existence are sufficient [15].In 1981, Abrham and Kotzig introduced the extended Skolem sequence, here the zero is allowed to occur anywhere in the sequence [1].The concept of a near Skolem sequence was first introduced by Stanton and Gouldon in 1981, in connection with the construction of cyclic Steiner triple systems [25].Shalaby, in 1992, showed necessary conditions to be sufficient for the existence of hooked, and hooked near-Skolem sequences [19].
In 1957, C. Dudley Langford, observed that his son had arranged coloured blocks such that there were three coloured pairs: red, blue, and yellow, where there was one block between the red pair, two blocks between the blue pair, and three blocks between the yellow pair.Langford generalized from colours to numbers.The coloured sequence takes the numeric form (3, 1, 2, 1, 3, 2).This is known as a Langford sequence of order n = 3 [7].
In 1959, Priday and Davies showed necessary and sufficient conditions for the existence of Langford sequences of order n [16].Priday generalized to allow for a zero, or hook, to appear at position 2n of a Langford sequence of length 2n + 1.He called these sequences hooked Langford sequences, while giving the original sequences the name of perfect Langford sequences.Davies showed necessary and sufficient conditions for the existence of hooked Langford sequences and gave proofs of necessary conditions for both perfect and hooked Langford sequences [16].
In 1983, Simpson proved sufficient conditions for existence of perfect Langford sequences with the addition of the defect d variable indicating the lower bound of the range of integers to include in the sequence [22].He also showed necessary and sufficient conditions for the hooked versions of these Langford sequences [22].
Additional generalizations were introduced when, in 1966, Gillespie and Utz defined the s-Langford sequence of order n and multiplicity s [4], [21].This is a sequence of sn integers from the set {1, . . ., n} with s copies of each and between each successive copy of an element b there are b spaces.In 1968, Levine was able to give necessary conditions for the existence of generalized Langford sequences of order s = p e t, where p is the smallest prime factor in s and e,t are any positive integers [8].In 1971, Roselle introduced the generalized (s, n)-Skolem sequence, where adding a 1 to each element and appending s copies of 1 to an end yields a generalized Skolem sequence of order n + 1.This is called Nickerson's notation, and was introduced in 1966 [11], and solved by him in 1974 [12].In 1971, Roselle introduced the generalized (s,n) Skolem sequence as a generalized s-Langford sequence that starts from 0 rather than 1 [17].In 1971, Rosell and Thomasson also generalized the necessary conditions for existence of s-Langford sequences [18].In 1998, Shalaby and Al-Gwaiz introduced the generalized hooked, extended, and near Skolem sequences, and determined necessary conditions for their existence, lower bounds for the number of zeros and their permissible locations [21].
These sequences have been very well studied due to significant applications in several branches of discrete mathematics including graph labelling and design theory [20].Skolem showed that the existence of a Steiner Triple System ST S(6n + 1) is given by the existence of a Skolem sequence of order n.He used a transformation from the Skolem sequence to the base blocks of the ST S(6n+1) [24].It was also shown that the existence of a ST S(6n + 3) is given by the existence of a hooked Skolem sequence of n [24].The corresponding applications of the generalized Skolem and Langford sequences are not yet known but it considered to be only a matter of time.
Expanding on previous results, this paper presents exciting new results for generalized Skolem and Langford sequences with minimum number of zeros.It generalizes the necessary conditions for this existence and locations for each zero for generalized Langford sequences, as well as implement new algorithms to find sequences and analyze the space of solutions for a range of cases.The paper gives expanded tables of computational results, along with several efficient probabilistic ways of searching for solutions in the very large cases.

Definitions
A Skolem sequence [21] of order n is a sequence S = (a 1 , a 2 , . . ., a 2n ) of 2n integers satisfying the conditions 1.For every b ∈ {1, 2, . . ., n} there exist exactly two elements, a i and a j , in S, such that a i = a j = b.

If a
All 6 Skolem sequences of order n = 4 are given by the following sequences and their reverses, A generalized Skolem sequence of order n and multiplicity s is a sequence GS = (a i 1 , a i 2 , . . ., a i sn ), i ∈ {1, . . ., s}, of sn integers from {1, 2, . . ., n} satisfying the conditions 1.For every b ∈ {1, 2, . . ., n} and every i ∈ {1, . . ., s} there exist exactly s elements in GS, {a i j 1 , a i i j 2 , . . ., a i js }, such that a i j 1 = a i j 2 = . . .= a i js = b.
2. If a i ju = a i j u+1 = b, then j u+1 − j u = b, (1 ≤ u ≤ s − 1).(in case of no ambiguity we skip the superscript i).
2. If a i ju = a i j u+1 = b then j u+1 − j u = b, (1 ≤ u ≤ s − 1).If the minimum number of zeros h of a generalized (extended) Skolem sequence of multiplicity s and order n, occupy exactly locations a ns−(i−1)p where 1 ≤ i ≤ h, then the sequence is called a generalized hooked Skolem sequence and the zeros can be called hooks.

If a
An example of a Langford sequence of order n = 3 is Notice that for a sequence in this notation, if each element is incremented by 1, and (1, 1) is appended to the end, then the sequence is a solution to the familiar Skolem sequence case with order n = 4, (4, 2, 3, 2, 4, 3, 1, 1) A slightly more general form of Langford's original sequence was first introduced by Bermond, Brouwer, and Germa [2] but associated with Langford sequences by Simpson [22].This is to distribute the numbers {1, 2, . . ., 2n} into n pairs (a i , b i ) such that the n numbers b i −a i , 1 ≤ i ≤ n, are all of the integers in the set {d, d+1, . . ., d+n−1} [22].So, the original Langford sequence would be the case where d = 2 in this version of the problem.A further generalization, introduced here based on this notation used by Simpson [22], and the concept of s-Langford sequence introduced by Gilespie and Utz [4], is to allow for a higher multiplicity s of elements in the sequence and use the elements from the set {d, d + 1, . . ., d + n − 1} where d would be the defect and n the order.This generalized sequence is defined as follows.
Generally, in this paper, when referring to the sequences as generalized Langford sequences in this paper, the intention will be to allow for zeros, and hence to use the extended version, but to also allow for the perfect subcase where the number of zeros h = 0.
( And finally, if the minimum number of zeros h of a generalized extended Langford sequence of multiplicity s, defect d, and order n, occupy exactly locations a sn+ h/p p−pi where 1 ≤ i ≤ h, then the sequence is called a generalized hooked Langford sequence and the zeros can be called hooks. 2 of the 10 total [14] hooked sequences from case (s, d, n, h) = (2, 3, 6, 1) are as follows. ( Another new result is presented for number of generalized hooked Langford sequences of case (s, d, n, h) = (4, 1, 18, 3), where 3 is the minimum number of zeroes in the specified permissible locations.There are exactly 2 solutions for this case [14].An example sequence from this case is given.( The application of the generalized hooked sequences with multiplicity s > 2 are not yet known.Although, the hooked sequences with multiplicity s = 2 can be used to generate cases of Steiner Triple Systems which the perfect sequences can not [20].

New Results
The following new results are introduced and extend those for (s, n)-Langford sequences [18] and generalized Skolem sequences [21], with the addition of the new defect variable d and a slight change to the calculation of k due to it's dependence on the value of d.
Theorem 1.Let s = p e t, where p is the smallest prime factor in s and e,t are any positive integers.Then a necessary condition for a generalized Langford sequence of multiplicity s, order n, and defect d > 0 to exist is that n satisfy one of the congruency classes, where (d − 1) ≡ j (mod p).
Corollary 2. A generalized Langford sequence of order n, defect d, and multiplicity s = tp e , has the same necessary conditions for existence as a generalized Skolem sequence of order n and multiplicity s, if and only if d ≡ 1 (mod p).
Proof.Let GL = (a 1 , a 2 , . . ., a sn ) be a generalized Langford sequence of order n, defect d, multiplicity s = tp e , p is the smallest prime factor in s, t > 0 and e > 0.
is the number of those elements less than or equal to d + n − 1 and d−1 p is the number less than or equal to d − 1.
For every b in the set of elements E = {d, d + 1, . . ., d + n − 1}, two observations are made: 1.If b ≡ 0 (mod p), then the number (i − 1)p + j will force b to be distributed equally among the residue classes of p; that is, b will appear in every column exactly tp e−1 times.
2. If b ≡ 0 (mod p), then b will appear all p e t times in a single column.
The second condition implies that to have a perfect sequence, the number of elements in E = {d, d + 1, . . ., d + n − 1} which are divisible by p must be a multiple of p.That is, The technique used here is similar to the proofs of necessary conditions for existence results in [18] and [21], for (s, n)-Langford sequences and generalized Skolem sequences, respectively.At this point in those proofs, the authors simply say "and this implies n must satisfy one of the conditions . . .", and state the necessary conditions.We prove this in a precise way for generalized Langford sequences as defined here.
First note that if E 1 = {b ∈ E : b ≡ 0 (mod p)}, then the number of elements in E 1 that will appear in a single column, without multiplicity copies, is given by tp e−1 .Since there are p columns in the matrix, the condition that follows from this is, and Therefore, for a generalized Langford sequence of order n, defect d, multiplicity s = tp e to exist, n must satisfy one of the following congruency classes, n ≡ −j, 1 − j, . . ., p − 1 − j (mod p e+1 ) where (d − 1) ≡ j (mod p).
So, for this generalized Langford sequence to have the same necessary conditions of existence as a generalized Skolem sequence, the following condition must hold, (mod p) ≡ 0 ≡ p = k, then the sequence is a perfect sequence, which is a subcase of the extended case where h = (p − k)(s − 1) = (p − p)(s − 1) = 0.So the range for k is actually 1 ≤ k ≤ p if the perfect subcase is included, otherwise the range is 1 ≤ k < p.The proof of these results will not include the perfect (h = 0) subcase as it has already been proved for theorem 1.Consider now the (ntp e−1 + h/p ) × p matrix B = (b i,j ) = (a (i−1)p+j ), where 1 ≤ j ≤ p and Again, for every b in the set of elements E = {d, d + 1, . . ., d + n − 1}, two observations are made: 1.If b ≡ 0 (mod p), then the number (i − 1)p + j will force b to be distributed equally among the residue classes of p; that is, b will appear in every column exactly tp e−1 times.
2. If b ≡ 0 (mod p), then b will appear all p e t times in a single column.
The second condition implies that to have a perfect sequence, the number of elements in E = {d, d + 1, . . ., d + n − 1} which are divisible by p must be a multiple of p.That is, For example, consider the perfect sequence for the case (s, d, n, h) = (3, 3, 8, 0) given below in matrix form.Note s = tp e =⇒ p = 3, t = 1, e = 1.If M is not a multiple of p, then say Now note that if E 1 = {b ∈ E : b ≡ 0 (mod p)}, then the number of elements from E 1 that will appear in a single column, without multiplicity copies, is equal to tp e−1 .Since there are p columns in the matrix, the condition that follows from this is, and Therefore, for a generalized (extended) Langford sequence of order n, defect d, multiplicity s = tp e to exist, n must satisfy one of the following congruency classes, where (d − 1) ≡ j (mod p) and n+d−1 p The matrix B will have (p − k) columns each containing s = p e t zeros, where the lower bound is attained when the entries b ntp e−1 ,q+1 , b ntp e−1 ,q+2 , . . ., b ntp e−1 ,p are all 0, or , but these all lie outside the sequence, so the lower bound for the number of zeros is h = (p − k)(s − 1), and since (b i,j ) = (a (i−1)p+j ), where 1 ≤ j ≤ p and 1 ≤ i ≤ ntp e−1 + h/p , the permissible locations for zeros are exactly, Since the number of entries in the matrix is sn + h/p p, the hooked sequences are those where the zeros occupy exactly locations, a sn+ h/p p−pi where 1 ≤ i ≤ h.
Consider a sequence for the case (s, d, n, h) = (3,3,10,4) given below in matrix form.Note s = tp e =⇒ p = 3, t = 1, e = 1.Now, the permissible locations of the zeros is calculated as a i such that which is in fact the case for the given sequence, where the zeros are located at positions 3, 12, 29, and 32, of which 3, 12 ≡ 0 (mod 3) and 29, 32 ≡ 2 (mod 3).Now consider a hooked sequence for the case (s, d, n, h) = (3, 3, 5, 2) given below in matrix form.Note s = tp e =⇒ p = 3, t = 1, e = 1.Now, the permissible locations of the zeros is calculated as a i such that and the exact location of the hooks is calculated as a j such that This is in fact the case for the given sequence, where 15, 12 ≡ 0 (mod 3).
Consider a hooked sequence for the case (s, d, n, h) = (4, 1, 18, 3) given below in (transpose) matrix form.Note s = tp e =⇒ p = 2, t = 1, e = 2. and Now, the permissible locations of the zeros is calculated as a i such that i ≡ k + 1, . . ., p − 1, 0 (mod p) =⇒ i ≡ 0 (mod p) and the exact location of the hooks is calculated as a j such that This is in fact the case for the given sequence, where 74, 72, 70 ≡ 0 (mod 2).

New Algorithms
There have been several types of algorithms used for searching the (generalized) Skolem and Langford solution space; exhaustive search to find all sequences and Hillclimbing to find at least one such sequence [3] [9].In addition to these algorithms, there have been very interesting algebraic methods based on generating functions for finding the number of solutions for a given instance of the problem [6] [9].Some of the algorithms involved parallalization [6] [5].
There are several algorithms used for exploring the generalized Langford problem space in this paper; the most important being the "worker algorithm", this algorithm does a non-recursive depth-first exhaustive search for perfect, hooked, and extended generalized Langford sequences.
The implementation used was a simplified version of the algorithm provided in the next section, written in the C programming language.These algorithms used the reversibility of the sequences so that it was only necessary to traverse half of the solution space.This simplification was extended with parallelization based on generating a number of starting sequences by searching the space in a breadth-first search manner and saving each position as a starting point for a worker.The algorithm which is described in the next section was intended to be a tool for exploring and experimenting with problem spaces, and not necessarily for efficiency, it provides a flexible and extendible framework to work with.For instance, a randomized customization of the algorithm, discussed in the next section, finds a sequence in just seconds that in the past many weeks were necessary.

Searching the generalized Skolem and Langford sequence space
Given multiplicity s = tp e , order n, defect d, and number of zeros h, this algorithm searches for generalized Langford sequences of sn+h elements from s copies of the set A = {d, d+1, ..., d+n−1} by generating valid positions to search at each element k ∈ A, and iterating through these elements and their positions searching in a depth-first search manner.The algorithm given is a non-recursive algorithm for traversing the search space of generalized Skolem and Langford type sequences.
N will represent number of sequences found B will represent a stack of backward elements F will represent a stack of forward elements Q will be a map of element to a queue of element position indices available to that element in the current search state S will be initialized as a list identifying the position of symmetry for the given sequence search case, it must calculated for each case.
A useful feature of the algorithm is that by providing a partial sequence on the initial call, the algorithm is able to populate the set of backward elements, along with the map of element position indices indicating the positions of the already placed elements, allowing the algorithm to essentially complete an existing partial sequence.And yet another feature of the implemented algorithm, which makes use of the modularized model of the algorithm, is the ability to add extenders or listeners at each main section of the algorithm: solutionFound, moveForward, moveBackward, generateElementPositionIndices; allowing the use of statistics listeners, lookahead extenders, and experimentation with alternate element position index generators.

Conclusion
This paper presented exciting new results for generalized Skolem and Langford sequences with minimum number of zeros.It generalizes the necessary conditions for this existence and locations for each zero for generalized Langford sequences, as well as providing new algorithm implementations and solution space analysis for a range of cases.New solutions were given for cases (s, d, n, h) = (4, 1, 24, 0) and (4, 1, 18, 3), as well as full exhaustive search results for many cases included in the appendix.A randomized approach to finding sequences in the solution space was given, including specific computational examples of it's effectiveness, where in the past a search may have taken several weeks to find a solution, and using the randomized algorithm a solution can be found in only seconds.
A continuation of this work would be to generalize the concept further to include a set of elements E = {b 1 , b 2 , . . ., b n } where n = |E|, rather than just the range of elements as in the generalize Langford sequences defined here.The theorem would then have k ≡ |{b ∈ E : b ≡ 0 (mod p)}|.If this could be worked out then, this gives necessary conditions for existence of these types of sequences, as well as expected minimum number of zeros and permissible locations of the zeros when they exist, all based on the value of k.The notion of allowing the set of elements A to be any set or multi-set of elements was given the name of multi-Skolem sequences by [13], so the appropriate name for the generalized form of this would be generalized (extended) multi-Skolem sequences.The algorithm described in this paper is very easily extended to search for these generalized (extended) multi-Skolem sequences.

Appendix for the new results
The following tables represent computational results for searches performed on the generalized Langford sequence space.The column variables represent multiplicity s = tp e , defect d, order n, calculated minimum number of zeros h = (p − k)(s − 1), actual minimum number of zeros h + , and number of distinct sequences N , where a sequence and it's reverse are both generally considered distinct.The reason h and h + could be different is that for smaller orders, and depending on the other parameters as well, the elements are just not able to fit into the sequence with expected minimum number of zeros, where the expected minimum h = (p−k)(s−1) is calculated using the value of k from Theorem 3, as you can see the values do match most of the time, confirming that in the general case Corollary 4 seems to holds.
In the second set of tables that follow, the column with label N H represent number of hooked solutions.
In all tables that follow, the reference column with entry [14] indicates new results introduced in this paper.22

1 p− d− 1 p
where p is the smallest prime factor in s and e,t are any positive integers.Then a necessary condition for a generalized (extended) Langford sequence of multiplicity s, order n, and defect d to exist is that n satisfy one of the congruency classes, n ≡ kp − j, kp + 1 − j, . . ., kp + (p − 1) − j (mod p e+1 ) where (d − 1) ≡ j (mod p) and d+n−≡ k (mod p).Corollary 4. If a generalized (extended) Langford sequence A = (a 1 , a 2 , . . ., a sn+h ) of order n, defect d, and multiplicity s = tp e exists, then the expected minimum number of zeros is given by h = (p − k)(s − 1)

Corollary 5 . 1 p− d− 1 p− 1 p since d+n− 1 p
If a generalized (extended) Langford sequence A = (a 1 , a 2 , . . ., a sn+h ) of order n, defect d, and multiplicity s = tp e exists with the number of zeros h the zeros can only occur in the locations a i , i ≡ k + 1, . . ., p − 1, 0 (mod p) where d+n−≡ k (mod p).Proof.Let GL = (a 1 , a 2 , . . ., a sn+h ) be a generalized (extended) Langford sequence of order n, defect d, multiplicity s = tp e and number of zeros h.If E = {d, d + 1, . . ., d + n − 1}, then the number of elements b ∈ E such that b ≡ 0 (mod p) is M = |{b ∈ E : b ≡ 0 (mod p)}| = d + n − 1 p − d is the number of those elements less than or equal to d + n − 1 and d−1 p is the number less than or equal to d − 1.