Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,13 @@
grid = MapThread[{#1,#2} &, {Range @ 16, Range @ 16}]
Move[x_] := (empty = Select[grid, #[[1]]==16 &][[1,2]];
If[(empty == x+4) || (empty == x-4) ||
(Mod[empty,4] != 0 && empty == x-1) ||
(Mod[empty,4] != 1 && empty == x+1),
oldEmpty = grid[[empty]][[1]];
grid[[empty]][[1]] = grid[[x]][[1]];
grid[[x]][[1]] = oldEmpty])
CButton[{x_,loc_}] := If[x==16, Null, Button[x,Move @ loc]]
Dynamic @ Grid @ Partition[CButton /@ grid,4]