您的当前位置:首页>新品 > 正文

百度上提供的4阶幻立方 到底完美不完美?

来源:CSDN 时间:2023-01-28 08:00:33

接上一篇


(相关资料图)

准备工作都做好了,现在来看看百度上提供的这个4阶幻立方到底完美不完美

1,8,61,60

62,59,2,7

52,53,16,9

15,10,51,54

第二层

48,41,20,21

19,22,47,42

29,28,33,40

34,39,30,27

第三层

49,56,13,12

14,11,50,55

4,5,64,57

63,58,3,6

第四层

32,25,36,37

35,38,31,26

45,44,17,24

18,23,46,43

*/

func testMagicCubeFour(){

var cubeFour: [[[Int]]] =

[

[

[1,8,61,60],

[62,59,2,7],

[52,53,16,9],

[15,10,51,54]

],

[

[48,41,20,21],

[19,22,47,42],

[29,28,33,40],

[34,39,30,27]

],

[

[49,56,13,12],

[14,11,50,55],

[4,5,64,57],

[63,58,3,6]

],

[

[32,25,36,37],

[35,38,31,26],

[45,44,17,24],

[18,23,46,43]

]

]

cubeFour = covertCube(cubeFour)

printMagicCube(cubeFour)

println("\nisMagicCube 检查")

let line1 = isMagicCube(cubeFour,true)

if let line1_ = line1 {

println("不是幻立方,line=\(line1_)")

}

}

//testMagicCubeFour()//放开即可打印

//下面是打印结果

/*

第0层

[1,8,61,60]

[62,59,2,7]

[52,53,16,9]

[15,10,51,54]

第1层

[48,41,20,21]

[19,22,47,42]

[29,28,33,40]

[34,39,30,27]

第2层

[49,56,13,12]

[14,11,50,55]

[4,5,64,57]

[63,58,3,6]

第3层

[32,25,36,37]

[35,38,31,26]

[45,44,17,24]

[18,23,46,43]

isMagicCube 检查

经检查,行的和都是相等的

经检查,列的和都是相等的

经检查,深的和都是相等的

前视图的各条对角线的和相等

不是幻立方,line=((0, 0, 0), (3, 0, 3))

*/

//也就是说左视图第一张主对角线的和不是幻和,不太完美,可惜

/*

下面再来看看同样是百度百科上的这个五阶标准幻立方实例

http://baike.baidu.com/link?url=2soOQvIeehXTDdFXctT3GPrkqQW5WdRkO-oBubYF41rLFDqkkh2WaOSbffkBhdkSTRTazRLSLop-a4UlNh_a2K

*/

func testMagicCubeFive(){

var cubeFive: [[[Int]]] =

[

[

[67, 18, 119,106,5 ],

[116,17, 14, 73, 95],

[40, 50, 81, 65, 79],

[56, 120,55, 49, 35],

[36, 110,46, 22, 101]

],

[

[66, 72, 27, 102,48],

[26, 39, 92, 44, 114],

[32, 93, 88, 83, 19],

[113,57, 9,  62, 74],

[78, 54, 99, 24, 60]

],

[

[42, 111,85, 2,  75],

[30, 118,21, 123,23],

[89, 68, 63, 58, 37],

[103,3,  105,8,  96],

[51, 15, 41, 124,84]

],

[

[115,98, 4,  1,  97],

[52, 64, 117,69, 13],

[107,43, 38, 33, 94],

[12, 82, 34, 87, 100],

[29, 28, 122,125,11]

],

[

[25, 16, 80, 104,90],

[91, 77, 71, 6,  70],

[47, 61, 45, 76, 86],

[31, 53, 112,109,10],

[121,108,7,  20, 59]

]

]

cubeFive = covertCube(cubeFive)

printMagicCube(cubeFive)

println("\nisMagicCube 检查")

let line1 = isMagicCube(cubeFive,true)

if let line1_ = line1 {

println("不是幻立方,line=\(line1_)")

}

}

//testMagicCubeFive()//放开即可打印

//下面是打印结果

/*

第0层

[67,18,119,106,5]

[116,17,14,73,95]

[40,50,81,65,79]

[56,120,55,49,35]

[36,110,46,22,101]

第1层

[66,72,27,102,48]

[26,39,92,44,114]

[32,93,88,83,19]

[113,57,9,62,74]

[78,54,99,24,60]

第2层

[42,111,85,2,75]

[30,118,21,123,23]

[89,68,63,58,37]

[103,3,105,8,96]

[51,15,41,124,84]

第3层

[115,98,4,1,97]

[52,64,117,69,13]

[107,43,38,33,94]

[12,82,34,87,100]

[29,28,122,125,11]

第4层

[25,16,80,104,90]

[91,77,71,6,70]

[47,61,45,76,86]

[31,53,112,109,10]

[121,108,7,20,59]

isMagicCube 检查

经检查,行的和都是相等的

经检查,列的和都是相等的

经检查,深的和都是相等的

前视图的各条对角线的和相等

左视图的各条对角线的和相等

俯视图的各条对角线的和相等

经检查,主对角线和是相等的

经检查,辅对角线row和是相等的

经检查,辅对角线col和是相等的

经检查,辅对角线deep和是相等的

*/

//这还真是个完美的5阶幻立方

/*

接下来看下齐鲁晚报网提供的一个7阶幻方

http://www.qlwb.com.cn/2015/0118/298452_2.shtml

看看它上面的数字,有些都黏在一起了

我是花了好多苦力活才把他们分开的

接下来我们检查下这个7阶幻立方完美程度

*/

func testMagicCubeSeven(){

var cubeSeven: [[[Int]]] =

[

[

[226, 252, 320, 45,  64,  139, 158],

[115, 183, 209, 277, 296, 28,  96],

[4,   72,  147, 166, 234, 253, 328],

[285, 304, 29,  55,  123, 191, 217],

[174, 242, 261, 336, 12,  80,  99],

[63,  131, 150, 218, 293, 312, 37],

[337, 20,  88,  107, 182, 201, 269]

],

[

[41,  60,  128, 154, 222, 290, 309],

[273, 341, 17,  85,  111, 179, 198],

[155, 230, 249, 317, 49,  68,  136],

[93,  119, 187, 206, 274, 300, 25],

[325, 1,   76,  144, 163, 238, 257],

[214, 282, 308, 33,  52,  120, 195],

[103, 171, 239, 265, 333, 9,   84]

],

[

[192, 211, 286, 305, 30,  56,  124],

[81,  100, 175, 243, 262, 330, 13],

[313, 38,  57,  132, 151, 219, 294],

[202, 270, 338, 21,  89,  108, 176],

[140, 159, 227, 246, 321, 46,  65],

[22,  97,  116, 184, 210, 278, 297],

[254, 329, 5,   73,  141, 167, 235]

],

[

[301, 26,  94,  113, 188, 207, 275],

[232, 258, 326, 2,   77,  145, 164],

[121, 196, 215, 283, 302, 34,  53],

[10,  78,  104, 172, 240, 266, 334],

[291, 310, 42,  61,  129, 148, 223],

[180, 199, 267, 342, 18,  86,  112],

[69,  137, 156, 231, 250, 318, 43]

],

[

[109, 177, 203, 271, 339, 15,  90],

[47,  66,  134, 160, 228, 247, 322],

[279, 298, 23,  98,  117, 185, 204],

[168, 236, 255, 323, 6,   74,  142],

[50,  125, 193, 212, 287, 306, 31],

[331, 14,  82,  101, 169, 244, 263],

[220, 288, 314, 39,  58,  133, 152]

],

[

[260, 335, 11,  79,  105, 173, 241],

[149, 224, 292, 311, 36,  62,  130],

[87,  106, 181, 200, 268, 343, 19],

[319, 44,  70,  138, 157, 225, 251],

[208, 276, 295, 27,  95,  114, 189],

[146, 165, 233, 259, 327, 3,   71],

[35,  54,  122, 190, 216, 284, 303]

],

[

[75,  143, 162, 237, 256, 324, 7],

[307, 32,  51,  126, 194, 213, 281],

[245, 264, 332, 8,   83,  102, 170],

[127, 153, 221, 289, 315, 40,  59],

[16,  91,  110, 178, 197, 272, 340],

[248, 316, 48,  67,  135, 161, 229],

[186, 205, 280, 299, 24,  92,  118]

]

]

cubeSeven = covertCube(cubeSeven)

printMagicCube(cubeSeven)

println("\nisMagicCube 检查")

let line1 = isMagicCube(cubeSeven,true)

if let line1_ = line1 {

println("不是幻立方,line=\(line1_)")

}

}

//testMagicCubeSeven()//放开即可打印

/*

第0层

[226,252,320,45,64,139,158]

[115,183,209,277,296,28,96]

[4,72,147,166,234,253,328]

[285,304,29,55,123,191,217]

[174,242,261,336,12,80,99]

[63,131,150,218,293,312,37]

[337,20,88,107,182,201,269]

第1层

[41,60,128,154,222,290,309]

[273,341,17,85,111,179,198]

[155,230,249,317,49,68,136]

[93,119,187,206,274,300,25]

[325,1,76,144,163,238,257]

[214,282,308,33,52,120,195]

[103,171,239,265,333,9,84]

第2层

[192,211,286,305,30,56,124]

[81,100,175,243,262,330,13]

[313,38,57,132,151,219,294]

[202,270,338,21,89,108,176]

[140,159,227,246,321,46,65]

[22,97,116,184,210,278,297]

[254,329,5,73,141,167,235]

第3层

[301,26,94,113,188,207,275]

[232,258,326,2,77,145,164]

[121,196,215,283,302,34,53]

[10,78,104,172,240,266,334]

[291,310,42,61,129,148,223]

[180,199,267,342,18,86,112]

[69,137,156,231,250,318,43]

第4层

[109,177,203,271,339,15,90]

[47,66,134,160,228,247,322]

[279,298,23,98,117,185,204]

[168,236,255,323,6,74,142]

[50,125,193,212,287,306,31]

[331,14,82,101,169,244,263]

[220,288,314,39,58,133,152]

第5层

[260,335,11,79,105,173,241]

[149,224,292,311,36,62,130]

[87,106,181,200,268,343,19]

[319,44,70,138,157,225,251]

[208,276,295,27,95,114,189]

[146,165,233,259,327,3,71]

[35,54,122,190,216,284,303]

第6层

[75,143,162,237,256,324,7]

[307,32,51,126,194,213,281]

[245,264,332,8,83,102,170]

[127,153,221,289,315,40,59]

[16,91,110,178,197,272,340]

[248,316,48,67,135,161,229]

[186,205,280,299,24,92,118]

isMagicCube 检查

经检查,行的和都是相等的

经检查,列的和都是相等的

经检查,深的和都是相等的

前视图的各条对角线的和相等

左视图的各条对角线的和相等

俯视图的各条对角线的和相等

经检查,主对角线和是相等的

经检查,辅对角线row和是相等的

经检查,辅对角线col和是相等的

经检查,辅对角线deep和是相等的

//看这检查结果,真的是perfect,没浪费我一片苦心

标签:

最新新闻:

新闻放送
Top