# How to print chess board with array? [duplicate]

This question already has an answer here:

I am doing n-queen implementation with my own algorithm and I get solutions with Number.But,I want to get output with actual chess board.

This is my piece of code.

solutions(* array *)

MatrixForm[solutions]

MatrixForm[{{2,8,9,15},{3,5,12,14}}].


I want to know how to print to combine with GUI chess board by using my solutions array. Number represents positions of chess board. I am new to mathematica. Thanks.😊😊😊

@David Is this code work for dynamic array?My solutions is for the size of n=4 and get 2 solutions.

## marked as duplicate by Anton Antonov, m_goldberg, José Antonio Díaz Navas, Thies Heidecke, bbgodfreyJan 11 at 0:53

• I actually trouble in plz😞😞😞 – Thuriya Thwin Jan 7 at 16:43
• Related: 164930, 47590 – C. E. Jan 7 at 16:56

Graphics[
Table[{FaceForm[None], EdgeForm[Black], Rectangle[{1, 1}, {9, 9}],
FaceForm[If[OddQ[i + j], White, Black]],
Rectangle[{i, j}, {i + 1, j + 1}],
FaceForm[Red], Disk[{3.5, 4.5}, .5], Disk[{5.5, 7.5}, .5]},
{i, 1, 8, 1}, {j, 1, 8, 1}]
] Your MatrixForm[{{2,8,9,15},{3,5,12,14}}] makes no sense.

• Is this code work for dynamic array?My solutions is for the size of n=4 and get 2 solutions. – Thuriya Thwin Jan 7 at 17:21
• @ThuriyaThwin have included a dynamic option. Very primitive but will get you started to something mode robust. – Jose Enrique Calderon Jan 8 at 12:50

To do dymanic chess

Manipulate[Graphics[
Table[{FaceForm[None], EdgeForm[Black], Rectangle[{1, 1}, {9, 9}],
FaceForm[If[OddQ[i + j], White, Black]],
Rectangle[{i, j}, {i + 1, j + 1}],
FaceForm[Red], Disk[{4.5+.5*moveX, 4.5+.5*moveY}, .5], Disk[{5.5+.5*move2X, 7.5+.5*move2Y}, .5]},
{i, 1, 8, 1}, {j, 1, 8, 1}]
],{moveX,-6,8},{moveY,-6,8},{move2X,-8,6},{move2Y,-12,2}]