五连珠matlab,智慧珠游戏拼盘终于有了自己比较满意的解法

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

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}]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值