四元格雷码及其如何用于解决Ziggurat和其他Ziggu谜题
The Quaternary Gray Code and How It Can Be Used to Solve Ziggurat and Other Ziggu Puzzles
AI总结:
本文研究Ziggu指数谜题家族的解法,将状态编码为四元数,证明最短解状态数公式并揭示其与四元格雷码的关系,还提供高效算法及与Nurikabe网格的双射,丰富相关序列文献。
摘要:
我们研究了新型指数级谜题“Ziggu”家族的解法。这类谜题有p个部件,构成m个迷宫。我们将谜题状态编码为n=m+1位的四元数(基4),每位数字表示在一个迷宫中的水平或垂直位置。我们证明最短解的状态数为6·2ⁿ - 3n - 5(OEIS A101946)。该解唯一,从起始状态生成方式如下:进行最左侧的、不会撤销前一次修改的操作。若将“最左侧”替换为“最右侧”,则生成访问所有(3ⁿ⁺¹ - 1)/2个状态的唯一最长解(OEIS A003462)。因此,根据状态编码数、有效状态数或最小状态数随迷宫增加的增长方式,Ziggu谜题可视为四元、三元或二元谜题。经典格雷码谜题(如Spin-Out)提供了自然对比。有p个部件的格雷码谜题其唯一解的状态数为2ᵖ(OEIS A000079)或⌊(2/3)·2ᵖ⌋(OEIS A000975)。格雷码谜题解中访问的状态遵循二进制反射格雷码。我们证明Ziggu谜题遵循四元反射格雷码,因为最短和最长解均为此顺序的子列表。这些结果展示了如何从起始状态解决Ziggu谜题。我们还提供O(n)时间的排名、比较和后继算法,分别给出状态在解中的位置、两个状态的相对顺序以及下一个状态。尽管格雷码谜题有更简单的递归描述和后继规则,但Ziggu谜题生成其最短解的无循环算法更简单。两个家族共享一个比较函数。最后,我们通过提供Ziggu状态与2×n Nurikabe网格之间的双射,丰富了关于OEIS A101946的文献。
英文摘要:
We investigate solutions to the new "Ziggu" family of exponential puzzles. These puzzles have $p$ pieces that form $m$ mazes. We encode the puzzle state as an quaternary number (base $4$) with $n=m+1$ digits, where each digit gives the horizontal or vertical position in one maze. We show that the number of states on a shortest solution is $6 \cdot 2^n - 3n - 5$ (OEIS A101946). This solution is unique, and it is generated from the start as follows: make the leftmost modification that doesn't undo the previous modification. Replacing "leftmost" with "rightmost" instead generates the unique longest solution that visits all $(3^{n+1} - 1)/2$ states (OEIS A003462). Thus, Ziggu puzzles can be viewed as $4$-ary, $3$-ary, or $2$-ary puzzles based on how the number of state encodings, valid states, or minimum states grow with each additional maze. Classic Gray code puzzles (e.g., Spin-Out) provide natural comparisons. Gray code puzzles with $p$ pieces have $2^p$ (OEIS A000079) or $\lfloor \frac{2}{3} \cdot 2^p \rfloor$ (OEIS A000975) states on their unique solution. The states visited in a Gray code puzzle solution follow the binary reflected Gray code. We show that Ziggu puzzles follow the quaternary reflected Gray code, as the shortest and longest solutions are both sublists of this order. These results show how to solve Ziggu puzzles from the start. We also provide $O(n)$-time ranking, comparison, and successor algorithms, which give the state's position along a solution, the relative order of two states, and the next state, respectively. While Gray code puzzles have simpler recursive descriptions and successor rules, the Ziggu puzzle has a simpler loopless algorithm to generate its shortest solution. The two families share a comparison function. Finally, we enrich the literature on OEIS A101946 by providing a bijection between Ziggu states and $2\times n$ Nurikabe grids.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。