\begin{tikzpicture}[scale=0.5,transform shape] % Draw the grid \foreach \i in {0,...,3} { \foreach \j in {0,...,3} { \draw[fill=gray!20] (\i,\j) rectangle ++(1,1); } } % Draw the tiles with numbers \foreach \i/\j/\n/\color in {0/0/2/20, 1/1/4/40, 2/2/8/60, 2/3/16/80, 3/3/32/100} { \draw[fill=orange!\color] (\i,\j) rectangle ++(1,1); \node at (\i+0.5,\j+0.5) {\textbf{\n}}; } \begin{scope}[xshift=6cm] \foreach \i in {0,...,3} { \foreach \j in {0,...,3} { \draw[fill=gray!20] (\i,\j) rectangle ++(1,1); } } % Draw the tiles with numbers \foreach \i/\j/\n\color in {3/0/2/20, 3/1/4/40, 3/2/8/60, 2/3/16/80,3/3/32/100} { \draw[fill=orange!\color] (\i,\j) rectangle ++(1,1); \node at (\i+0.5,\j+0.5) {\textbf{\n}}; } \end{scope} \begin{scope}[xshift=12cm] \foreach \i in {0,...,3} { \foreach \j in {0,...,3} { \draw[fill=gray!20] (\i,\j) rectangle ++(1,1); } } % Draw the tiles with numbers \foreach \i/\j/\n/\color in {3/0/2/20, 3/1/4/40, 3/2/8/60, 3/3/32/100,1/0/2/20,2/3/16/80} { \draw[fill=orange!\color] (\i,\j) rectangle ++(1,1); \node at (\i+0.5,\j+0.5) {\textbf{\n}}; } \end{scope} \draw[thick, black,->] (2,4) -- (2,5) -- (8,5) -- (8,4) ; \draw[thick, black,->] (8,0) -- (8,-1) -- (14,-1) -- (14,0) ; \node at (5,4.5) {$a=$\textit{right}, $r=0$}; \node at (11.5,-0.5) {random tile}; \node at (-0.5,2) {$B_1=$}; \node at (5.5,2) {$B_1^{'} =$}; \node at (11.5,2) {$B_2=$}; \end{tikzpicture}