Mathematica 9 is now available
Student Support Forum
Student Support Forum > General > > "Colored checkerboard"

Post Reply:
Email Address:

Please send email when my message is replied to.

Url (optional):
Message: view original message?
Attachment (optional):
Please answer this:5+2 =

Original Message (ID '273996') By Bill Simpson:
I am assuming you mean you do not want two adjacent squares to have the same color. This generates a board of size*size and then checks to see that no two adjacent are the same number. If two adjacent are the same it generates a new board and tries again. In[1]:= size=2;count=0; While[True, t=Table[RandomInteger[3,{size,size}]; success=True;count++; For[i=1,i≤size,i++, For[j=1,j≤size,j++, If[i>1&&t[[i,j]]==t[[i-1,j]]|| i1&&t[[i,j]]==t[[i,j-1]]|| j