该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
MasterGraph =
VertexDelete[
Graph[EdgeList@
GridGraph@{10, 10}], _?(Subtract @@ IntegerDigits[# - 1, 10, 2] <
0 &)];
Turn[matrix_] :=
DeleteDuplicates@{matrix, Reverse /@ matrix,
Reverse /@ Reverse@matrix, Reverse@matrix, Transpose@matrix,
Transpose@Reverse@matrix, Transpose@Reverse[Reverse /@ matrix],
Transpose[Reverse /@ matrix]};
Boxs = {{{0, 1, 0}, {1, 1, 1}, {0, 1, 0}}, {{1, 1}, {1, 1}}, {{1, 1,
1, 1}}, {{0, 0, 1}, {0, 0, 1}, {1, 1, 1}}, {{0, 0, 1}, {0, 1,
1}, {1, 1, 0}}, {{1, 0, 1}, {1, 1, 1}}, {{0, 1}, {1, 1}}, {{0, 0,
1, 0}, {1, 1, 1, 1}}, {{0, 0, 1, 1}, {1, 1, 1, 0}}, {{0, 0, 0,
1}, {1, 1, 1, 1}}, {{0, 1, 1}, {1, 1, 1}}, {{0, 0, 1}, {1, 1,
1}}};
boxcount = Total[#, 2] & /@ Boxs;
BoxList =
Table[Select[
Join @@ (Flatten[
Table[(10 (#[[1]] + i - 1) + #[[2]] + j) & /@ #, {i, 0,
10 - Max @@ #[[;; , 1]]}, {j, 0, 10 - Max @@ #[[;; , 2]]}],
1] & /@ (Position[#, 1] & /@ Turn@x)), #~
Intersection~(VertexList@MasterGraph) == # &], {x, Boxs}];
AndList[list_] :=
Block[{x, y},
Flatten@Position[
CoefficientList[
Times @@ (Sum[x^(#[[1]] i), {i, 0, #[[2]]}] & /@ Tally[list]),
x], y_ /; (y > 0)] - 1];
NormalQ[graph_, number_, flag_] :=
Block[{cc, lcc, countlist, anybox}, cc = ConnectedComponents@graph;
lcc = Sort@DeleteDuplicates[Length /@ cc];
countlist =
If[flag == 0, Delete[boxcount, number], boxcount[[number ;;]]];
lcc \[Intersection] AndList[countlist] ==
lcc && (anybox =
Sort[Sort /@ Select[cc, MemberQ[countlist, Length@#] &]];
Intersection[anybox,
Flatten[If[flag == 0, Delete[BoxList, number],
BoxList[[number ;;]]], 1]] == anybox)];
Do[BoxList[[i]] =
Select[BoxList[[i]],
NormalQ[VertexDelete[MasterGraph, #], i, 0] &], {i, 12}];
BoxList[[3]] =
DeleteDuplicates[BoxList[[3]],
Sort[FromDigits@Reverse@IntegerDigits[100 - #, 10, 2] +
1 & /@ #1] == #2 &];
AppendBox[boxlist_, boxs_] :=
Append[boxlist, #] & /@
Select[boxs, Intersection[#, Join @@ boxlist] == {} &];
AppendBoxs[1] = {#} & /@ BoxList[[1]];
AppendBoxs[n_] :=
AppendBoxs[n] =
Select[Flatten[AppendBox[#, BoxList[[n]]] & /@ AppendBoxs[n - 1],
1], NormalQ[VertexDelete[MasterGraph, Join @@ #], n + 1, 1] &];
Timing@Do[Print@Timing@Length@AppendBoxs[i], {i, 12}]