%N Geometric length of the solution to the Towers of Hanoi exchanging disks puzzle with 3 pegs and n disks.
%C Scorer, Grundy and Smith define a variation of the towers of Hanoi puzzle where the smallest disk moves freely and two disks can exchange positions when they differ in size by 1, are on different pegs, and each is top-most on its peg. The puzzle is to move a stack of n disks from one peg to another.
%C Stockmeyer et al. determine the shortest solution to the puzzle. a(n) is their d(n) which is the geometric length of the solution when the state graph is embedded in a grid of unit triangles in the manner of the sample drawing by Scorer et al.
%C Graph n comprises 3 copies of graph n-1. The embedding arranges these 3 copies as a large triangle with a unit gap between the corners. The edges connecting these subgraphs are in the middle of the inner sides. A move of the smallest disk is length 1. An exchange of disks s and s+1 is length 2^s, where the smallest disk is s=0.
%H Kevin Ryde, <a href="/A341583/b341583.txt">Table of n, a(n) for n = 0..700</a>
%H Paul K. Stockmeyer et al., <a href="https://doi.org/10.1080/00207169508804452">Exchanging Disks in the Tower of Hanoi</a>, International Journal of Computer Mathematics, volume 59, number 1-2, pages 37-47, 1995. Also <a href="http://www.cs.wm.edu/~pkstoc/gov.pdf">author's copy</a>. a(n) = d(n) in section 5 exercise 5.
%H <a href="/index/Rec#order_05">Index entries for linear recurrences with constant coefficients</a>, signature (3,-1,-2,2,-4).
%H <a href="/index/To#Hanoi">Index entries for sequences related to Towers of Hanoi</a>
%F a(n) = (7*2^n - A341579(n+3) + A341579(n))/2.
%F a(n) = 3*a(n-1) - a(n-2) - 2*a(n-3) + 2*a(n-4) - 4*a(n-5).
%F G.f.: x * (1 - x) * (1 + x + x^2) / ( (1 - 2*x) * (1 - x - x^2 - 2*x^4) ).
%F G.f.: (7/2)/(1 - 2*x) - (1/2)*(7 + 5*x + 3*x^2 + 6*x^3)/(1 - x - x^2 - 2*x^4).
%e The graph embedding in a triangular grid is (as drawn by Scorer et al.),
%e / \ n=3 disks
%e *---* A to D
%e / \ geometric
%e * * length along
%e / \ / \ the path
%e *---B---*---* a(3) = 8
%e / \
%e * . \ *
%e / \ / \ / \
%e *---C *---*
%e / \ / \
%e * *-------* *
%e / \ / \ / \ / \
%e D---*---*---* *---*---*---*
%e B to C is where disks s=1 and s+1=2 exchange which is geometric length 2^s = 2.
%o (PARI) my(p=Mod('x,'x^4-'x^3-'x^2-2), f=7*'x^3+5*'x^2+3*'x+6); a(n) = (7<<n - polcoeff(lift(f*p^n),3))/2;
%Y Cf. A341579.
%A _Kevin Ryde_, Feb 16 2021