# 扫雷求解器

34

• `x`：不变
• `!`：标志
• 数字：该区域周围的地雷数量

``````10
0 0 1 x x x x x
0 0 2 x x x x x
0 0 2 ! x x x x
0 0 1 2 x x x x
0 0 0 1 x x x x
1 1 0 2 x x x x
x 1 0 2 x x x x
1 1 0 1 x x x x
``````

• `0`： 打开它
• `1`：放置标志

``````0 1 2
``````

• 您编写了一个完整的程序，该程序将单个字段作为输入（STDIN或命令行参数）并输出单个操作（STDOUT）。因此，除之外，您无法保存状态`!`
• 您的选择必须遵循最大的生存几率。（即，如果有100％安全的举动，请采取）
• 这是；最短的解决方案（以UTF-8字节为单位）获胜

``````4
x x x x
1 2 x x
0 1 2 x
0 0 1 x
``````

``````1 1 2
0 0 2
0 1 3
``````

``````2
x x x
1 ! x
1 1 x
``````

``````0 0 0
0 0 1
0 1 2
0 2 2
1 0 2
``````

``````10
x x x x x x x x
1 3 3 x x x x x
0 1 ! 3 3 4 x x
0 2 3 ! 2 3 x x
0 1 ! 2 2 ! x x
``````

``````1 1 5
1 0 2
``````

``````2
x x x
2 3 1
! 1 0
``````

``````0 0 1
1 0 0
1 0 2
``````

Claudiu 2014年

FDinoff 2014年

1

VISION

1
@JonathanVanMatre该字段是空白的，但可以保证您的第一个空缺不是地雷，因为第一次单击后就放置了地雷：)
TimWolla 2014年

2

Undergroundmonorail

17

## Mathematica

``````t = {{0, 0, 1, x, x, x, x, x}, {0, 0, 2, x, x, x, x, x}, {0, 0, 2, F, x, x, x, x},
{0, 0, 1, 2, x, x, x, x}, {0, 0, 0, 1, x, x, x, x}, {1, 1, 0, 2, x, x, x, x},
{x, 1, 0, 2, x, x, x, x}, {1, 1, 0, 1, x, x, x, x}};
(*Sqrt[2] is  1.5*)
c = Sequence; p = Position;
nums = p[t, _?NumberQ];
fx = Nearest[p[t, x]];
flagMinus[flag_] := If[Norm[# - flag] < 1.5, t[[c @@ #]]--] & /@ nums
flagMinus /@ p[t, F];
g@x_List := Tr[q[#] & /@ x]
eqs = MapIndexed[t[[c @@ (nums[[#2]][[1]])]] == g[#1] &, (fx[#, {8, 1.5}] & /@nums)];
vars = Union@Cases[eqs, _q, 4];
s = Solve[Join[eqs, Thread[0 <= vars < 2]], vars, Integers];
res = (Transpose@s)[[All, All, 2]];
i = 1; plays = Select[{i++, #[[1]], Equal @@ #} & /@ res, #[[3]] &];
Flatten /@ ({#[[2]] /. 1 -> F, List @@ vars[[#[[1]]]] - 1} & /@ plays)

(*
{{0, 0, 3}, {F, 1, 3}, {F, 2, 4}, {0, 3, 4}, {0, 4, 4},
{F, 5, 4}, {F, 6, 0}, {F, 6, 4}, {0, 7, 4}}
*)
``````

1. 下载http://pastebin.com/asLC47BW并将其另存为* .CDF
2. 从Wolfram Research在https://www.wolfram.com/cdf-player/下载免费的CDF环境 （不是小文件）