(* ::Package:: *)

(* ::Section:: *)
(*target*)


(* ::Input:: *)
(*n=12;*)


(* ::Input:: *)
(*target=\!\(\**)
(*TagBox[*)
(*RowBox[{"(", GridBox[{*)
(*{"189", "189", "189", "189", "189", "33", "33", "33", "189", "189", "189", "189"},*)
(*{"189", "189", "189", "33", "33", "33", "189", "33", "44", "189", "189", "189"},*)
(*{"189", "189", "189", "189", "189", "33", "33", "33", "33", "189", "189", "189"},*)
(*{"189", "189", "189", "189", "189", "33", "189", "33", "33", "189", "189", "189"},*)
(*{"189", "189", "189", "33", "33", "189", "189", "33", "33", "33", "189", "189"},*)
(*{"189", "134", "33", "33", "189", "189", "189", "189", "33", "33", "189", "189"},*)
(*{"189", "144", "33", "33", "189", "189", "189", "189", "33", "189", "189", "189"},*)
(*{"189", "142", "33", "33", "189", "189", "189", "189", "33", "33", "33", "189"},*)
(*{"189", "100", "142", "33", "189", "189", "189", "189", "33", "33", "33", "189"},*)
(*{"189", "142", "142", "189", "189", "189", "189", "189", "189", "33", "189", "189"},*)
(*{"189", "59", "142", "33", "189", "189", "189", "189", "33", "189", "189", "189"},*)
(*{"189", "189", "33", "33", "189", "189", "189", "189", "189", "189", "189", "189"}*)
(*},*)
(*GridBoxAlignment->{"Columns" -> {{Center}}, "Rows" -> {{Baseline}}},*)
(*GridBoxSpacings->{"Columns" -> {Offset[0.27999999999999997`], {Offset[0.7]}, Offset[0.27999999999999997`]}, "Rows" -> {Offset[0.2], {Offset[0.4]}, Offset[0.2]}}], ")"}],*)
(*Function[BoxForm`e$, MatrixForm[BoxForm`e$]]]\);*)


(* ::Section:: *)
(*1*)


(* ::Input:: *)
(*g[x_,y_]:=3t[x,y]+2(t[x-1,y]+t[x,y-1]+t[x+1,y]+t[x,y+1])+t[x-2,y]+t[x,y-2]+t[x+2,y]+t[x,y+2]//Expand*)


(* ::Input:: *)
(*t[x_,y_]:=If[1<=x<=n&&1<=y<=n,c[x,y],0];*)


(* ::Input:: *)
(*allC=Flatten@Table[c[i,j],{i,n},{j,n}];*)
(*eqns=Simplify@Flatten@Table[g[x,y]==target[[x,y]],{x,n},{y,n}];*)


(* ::Input:: *)
(*solution=allC/.FindInstance[eqns,allC,Modulus->256][[1]];*)
(*ans=Partition[solution,n];*)
(*ans//MatrixForm*)
