OFFSET
1,2
COMMENTS
In the cited paper by Klavzar et al. it is proved that Frame's algorithm and Stewart's algorithm, as well as several variations, all yield the same number of moves needed for the n disk, p peg problem, given by the formula for X(n,p).
This sequence lists the elements of the upper right triangle of the matrix having as rows the number of moves required, depending on the number of disks, for a given number of pegs. (The first row refers to 3 pegs, etc.) The lower left triangle of the matrix is uninteresting, since all elements below a given diagonal element are equal to that element, namely 2n-1. (For p>n, each disk can be moved to a separate peg.)
However, the article by Klavžar and Milutinović, "Simple explicit formulas for the Frame-Stewart numbers", points out that there is (at least as of 2002) no proof that this algorithm is optimal. - N. J. A. Sloane, Sep 10 2018
REFERENCES
Klavžar, Sandi, and Uroš Milutinović. "Simple explicit formulas for the Frame-Stewart numbers." Annals of Combinatorics 6.2 (2002): 157-167; 0218-0006/02/020157-11. [This is an 11-page article. There is a free article on the web with the same authors and title, but which is only two pages long. - N. J. A. Sloane, Sep 10 2018]
LINKS
S. Klavzar et al., On the Frame-Stewart algorithm for the multi-peg Tower of Hanoi problem, Discrete Applied Mathematics 120 (2002) 141-15 and references therein.
FORMULA
X(n,p) = Sum_{t=0..s-1} 2^t*binomial(p-3+t,p-3) + 2^s*(n-binomial(p-3+s,p-2)) where s = max { k in Z | n > binomial(p-3+k,p-2) }.
EXAMPLE
The complete matrix would read:
1 3 7 15 31 63 127 255 511 1023 ...
1 3 5 9 13 17 25 33 41 49 ...
1 3 5 7 11 15 19 23 27 31 ...
1 3 5 7 9 13 17 21 25 29 ...
1 3 5 7 9 11 15 19 23 27 ...
1 3 5 7 9 11 13 17 21 25 ...
1 3 5 7 9 11 13 15 19 23 ...
1 3 5 7 9 11 13 15 17 21 ...
1 3 5 7 9 11 13 15 17 19 ...
MATHEMATICA
s[n_, p_] := (k = 0; While[ n > Binomial[p - 3 + k++, p - 2] ] ; k - 2); x[n_, p_] := (snp = s[n, p]; Sum[2^t*Binomial[p - 3 + t, p - 3], {t, 0, snp - 1}] + 2^snp*(n - Binomial[p - 3 + snp, p - 2])); Flatten[Table[x[n, p], {n, 1, 12}, {p, 3, n + 2}] ] (* Jean-François Alcover, Jun 01 2011 *)
PROG
(PARI) X(n, p)={local(s=1, t=0); while( n>binomial(p-2+t++, p-2), s+=2^t*binomial(p-3+t, p-3)); s+2^t*(n-binomial(p-3+t, p-2))}
A137695(n)=X(t=1+sqrtint(2*n-2-sqrtint(2*n-2)), 2+n-t*(t-1)/2)
CROSSREFS
KEYWORD
AUTHOR
M. F. Hasler, Feb 09 2008, revised Feb 10 2008
STATUS
approved