login
Number of perfect mazes on an n X n grid, including a discontiguous, directed pair of unit-length entry and exit openings in the border, with rotations and reflections not counted as distinct.
2

%I #34 Feb 25 2026 21:34:27

%S 1,21,2708,2702336,24410499168,2104896553943040,

%T 1778444003240055248640,14939769469723143490555084800,

%U 1259088365662049769772300690661574656,1070947202979258392244674442279023145910272000,9231770604513665531846104652770226955879223011179905024

%N Number of perfect mazes on an n X n grid, including a discontiguous, directed pair of unit-length entry and exit openings in the border, with rotations and reflections not counted as distinct.

%C Counting the entry/exit pairs as nondirected gives A390017. a(n) = 2*A390017(n) minus 1 for each symmetric case, except for cases which have only 2-way reflection symmetry and both openings intersecting the reflection axis (applies only to odd n), e.g. 3 cases for n = 3:

%C _ _ _ _ _ _

%C | | | | | | | | | |

%C | | | | |_ _| |_| |_|

%C |_ _| |_ _| |_ _|

%e For a(2) = 21, the 9 nonsymmetric cases counting twice each (once for each entry/exit direction) are:

%e _ _ _ _ _

%e |_ | |_ | _| | _ | _|

%e _ _| |_ _| |_ | |_ _| |_ _

%e _ _ _ _

%e | | | | | | |

%e | |_| |_| | |_|_| |_|_

%e and the 3 symmetric cases counting once each (entry/exit directions are congruent through reflection) are:

%e _ _

%e | | | |_ | | _|

%e |_ _| | _| | _|

%o (PARI) vector(11,n,A392623(n)) \\ See Links in A390017 for program code. - _Andrew Howroyd_, Feb 22 2026

%Y Cf. A349718, A390017.

%K nonn

%O 1,2

%A _Charles L. Hohn_, Feb 15 2026

%E a(6) onward from _Andrew Howroyd_, Feb 22 2026