(* Problem:   Express the vector
 w =(7,3,13) 
as a linear combination of the vectors 
v1 =(1,2,3), 
   v2 =(4,1,2), and  
 v3 = (1,1,0) *)

(* Solution: Create the matrix whose COLUMNS are v1, v2, and v3.
Then use the command

LinearSolve[A,w]

*)

A={{1,1,4},{0,2,1},{4,3,2}}
MatrixForm[A]

w={7,3,13};
LinearSolve[A,w]

(* Thus we see that w = 2 v1 + v2 + v3 *)

(*  Now here's the code we looked at in class for the LIGHTS OUT problem *)

n=5
Gam=Table[0, {i,n}, {j,n},{k,n},{l,n}];
For[i=1,i≤n,i++,
For[j=1, j≤n , j++,{
Gam[[i,j,i,j]]=1,
If[(i>1), Gam[[i,j,i-1,j]]=1],
If[(i<n), Gam[[i,j,i+1,j]]=1],
If[(j>1), Gam[[i,j,i,j-1]]=1],
If[(j<n), Gam[[i,j,i,j+1]]=1],

Print[MatrixForm[Table[Gam[[i,j,k,l]],{k,n},{l,n}]]]; 
}
]
]
BigMat=Partition[Flatten[Gam],n^2];
Print[MatrixForm[BigMat]]

InitialConfiguration={1,1,1,0,1,1,0,1,0,0,1,0,1,0,1,0,1,0,1,1,1,1,0,0,1}; (*Initial configuration, read row by row *)
ASolution=LinearSolve[BigMat,InitialConfiguration, Modulus->2];
(* LinearSolve finds a solution by writing the initial configuration as a linear combination of the Gammas *)
MatrixForm[Partition[ASolution,5]]
(* This command displays the solution as an easy-to-read 5x5 matrix *)

(* This matrix tells you which squares to click on to solve the puzzle *)