连续的{0~35}填不成,我们退而求其次,自然要求填入的数组尽可能洞断之处少。
1个洞的数组,是从{0~36}中挖一个洞,∑{0~36}≡18(mod36), 故挖去的洞为18.
化为正负对称的零和数组,即{-18, -17, ..., -2, -1, 1, 2, ..., 17, 18}.
这个现在又被否决了。
2个洞的数组,是从{0~37}中挖两个洞,∑{0~37}≡19(mod36), 所以挖去的两个洞之和须为19或者55.
这有{1+18, 2+17, ..., 9+10}以及{19+36, 20+35, ..., 27+28}共18种双洞组合。
由于对称性,实际上只有9种,取后9种就代表了。
3个洞的数组,要从{0~38}中挖3个洞,∑{0~38}≡21(mod36), 所以挖去的3个洞之和须为21、57或者93.
21与93的组是对称同构的,取其一即可,共是27种3洞组合:
- In[1]:= Select[IntegerPartitions[21, {3}], DuplicateFreeQ]
- Out[1]= {{18, 2, 1}, {17, 3, 1}, {16, 4, 1}, {16, 3, 2}, {15, 5, 1}, {15, 4, 2}, {14, 6, 1}, {14, 5, 2}, {14, 4, 3},
- {13, 7, 1}, {13, 6, 2}, {13, 5, 3}, {12, 8, 1}, {12, 7, 2}, {12, 6, 3}, {12, 5, 4}, {11, 9, 1}, {11, 8, 2}, {11, 7, 3},
- {11, 6, 4}, {10, 9, 2}, {10, 8, 3}, {10, 7, 4}, {10, 6, 5}, {9, 8, 4}, {9, 7, 5}, {8, 7, 6}}
复制代码
57的组,共162种三洞组合:
- In[2]:= Select[IntegerPartitions[57, {3}, Range[37]], DuplicateFreeQ]
- Out[2]= {{37, 19, 1}, {37, 18, 2}, {37, 17, 3}, {37, 16, 4}, {37, 15, 5}, {37, 14, 6}, {37, 13, 7}, {37, 12, 8}, {37, 11, 9}, {36, 20, 1}, {36, 19, 2}, {36, 18, 3}, {36, 17, 4}, {36, 16, 5}, {36, 15, 6}, {36, 14, 7}, {36, 13, 8}, {36, 12, 9}, {36, 11, 10}, {35, 21, 1}, {35, 20, 2}, {35, 19, 3}, {35, 18, 4}, {35, 17, 5}, {35, 16, 6}, {35, 15, 7}, {35, 14, 8}, {35, 13, 9}, {35, 12, 10}, {34, 22, 1}, {34, 21, 2}, {34, 20, 3}, {34, 19, 4}, {34, 18, 5}, {34, 17, 6}, {34, 16, 7}, {34, 15, 8}, {34, 14, 9}, {34, 13, 10}, {34, 12, 11}, {33, 23, 1}, {33, 22, 2}, {33, 21, 3}, {33, 20, 4}, {33, 19, 5}, {33, 18, 6}, {33, 17, 7}, {33, 16, 8}, {33, 15, 9}, {33, 14,10}, {33, 13, 11}, {32, 24, 1}, {32, 23, 2}, {32, 22, 3}, {32, 21,4}, {32, 20, 5}, {32, 19, 6}, {32, 18, 7}, {32, 17, 8}, {32, 16, 9}, {32, 15, 10}, {32, 14, 11}, {32, 13, 12}, {31, 25, 1}, {31, 24, 2}, {31, 23, 3}, {31, 22, 4}, {31, 21, 5}, {31, 20, 6}, {31, 19, 7}, {31, 18, 8}, {31, 17, 9}, {31, 16, 10}, {31, 15, 11}, {31, 14,12}, {30, 26, 1}, {30, 25, 2}, {30, 24, 3}, {30, 23, 4}, {30, 22, 5}, {30, 21, 6}, {30, 20, 7}, {30, 19, 8}, {30, 18, 9}, {30, 17, 10}, {30, 16, 11}, {30, 15, 12}, {30, 14, 13}, {29, 27, 1}, {29, 26,2}, {29, 25, 3}, {29, 24, 4}, {29, 23, 5}, {29, 22, 6}, {29, 21, 7}, {29, 20, 8}, {29, 19, 9}, {29, 18, 10}, {29, 17, 11}, {29, 16, 12}, {29, 15, 13}, {28, 27, 2}, {28, 26, 3}, {28, 25, 4}, {28, 24, 5}, {28, 23, 6}, {28, 22, 7}, {28, 21, 8}, {28, 20, 9}, {28, 19, 10}, {28, 18, 11}, {28, 17, 12}, {28, 16, 13}, {28, 15, 14}, {27, 26, 4}, {27, 25, 5}, {27, 24, 6}, {27, 23, 7}, {27, 22, 8}, {27, 21, 9}, {27, 20, 10}, {27, 19, 11}, {27, 18, 12}, {27, 17, 13}, {27, 16, 14}, {26, 25, 6}, {26, 24, 7}, {26, 23, 8}, {26, 22, 9}, {26, 21, 10}, {26, 20, 11}, {26, 19, 12}, {26, 18, 13}, {26, 17, 14}, {26, 16, 15}, {25, 24, 8}, {25, 23, 9}, {25, 22, 10}, {25, 21, 11}, {25, 20, 12}, {25, 19, 13}, {25, 18, 14}, {25, 17, 15}, {24, 23, 10}, {24, 22, 11}, {24, 21, 12}, {24, 20, 13}, {24, 19,14}, {24, 18, 15}, {24, 17, 16}, {23, 22, 12}, {23, 21, 13}, {23, 20, 14}, {23, 19, 15}, {23, 18, 16}, {22, 21, 14}, {22, 20, 15}, {22, 19, 16}, {22, 18, 17}, {21, 20, 16}, {21, 19, 17}, {20, 19, 18}}
复制代码
其中含中位数19的计18种:{37,19,1}, (36,19,2}, ..., {20,19,18};
不含19的剩144种,由于成对对称同构,折半为72种。
合计90种。
@mathe搜到的两个(1-39)幻方的3洞都是{14, 20, 26}, 化成0~38即{13, 19, 25}。有一个洞在中位,前后两洞对称。
这3个洞把数组划分成4段,长度组合为13+5+5+13,这有点出人意料,我以为应该是12+6+6+12的。
2个洞的数组,我猜想也填不成,所以mathe应该是达到最优解了。
记得有个叫苏茂挺的解过6阶泛对角幻方(比这里定义的模幻方约束少,对称度低一些),得到的最优解有十几个洞吧。
不过他是手工解的,能达到这样我还是很佩服。我编程猫到的最好结果也有25个洞呢。
|