# Where in the Square?

Another week, another riddler. This week’s was a puzzle I’d submitted:

You are given an empty 4-by-4 square and one marker. You can color in the individual squares or leave them untouched. After you color as many or as few squares as you’d like, I will secretly cut out a 2-by-2 piece of it and then show it to you without rotating it. You then have to tell me where it was (e.g., “top middle” or “bottom right,” etc.) in the original 4-by-4 square.

Can you design a square for which you’ll always know where the piece came from?

For this I brute forced the problem and checked every possible square — turns out there are 6188 correct answers. Here are 150 of them: And here is the code:

```from matplotlib import pyplot as plt
from matplotlib.colors import ListedColormap
import numpy as np

def render_square(sq):
plt.matshow(sq,cmap=plt.cm.ocean)
plt.xticks([])
plt.yticks([])
plt.show()

def render_squares(total_sqs):

rows = 10
cols = 15
newcmp = ListedColormap(['#F29A8B','#30333A'])
fig, axes = plt.subplots(nrows=rows, ncols=cols, sharex=True, sharey=True)

for x in range(cols):
for y in range(rows):
axes[y,x].matshow(total_sqs[x*cols + y],cmap=newcmp)
axes[y,x].set_axis_off()

plt.axis('off')
fig.subplots_adjust(left=0, right=1, top=1, bottom=0, wspace=0.1, hspace=0.1)
fig.patch.set_facecolor('#F6EEDA')
plt.show()

def check_if_locatable(source):
squares = set()

#top_left

#top_middle

#top_right

#mid_left

#mid_middle

#mid_right

#bot_left

#bot_middle

#bot_right

if len(squares) == 9: return True

def check_all_squares():
total_sq = 0
total_sqs = []

sq_size = 4
sq_cells = sq_size**2
bin_max = 2**sq_cells
for i in range(bin_max):
sq = []
sq_vals = str(bin(i)[2:]).zfill(sq_cells)
for row in range(sq_size):
row_val = sq_vals[row*sq_size:(row+1)*sq_size]
row_val_list = list(row_val)
for i in range(sq_size): row_val_list[i] = int(row_val_list[i])

sq.append(row_val_list)

if check_if_locatable(sq):
total_sq += 1
total_sqs.append(sq)

render_squares(total_sqs)

check_all_squares()

```

## 2 thoughts on “Where in the Square?”

1. Pingback: Can You Escape This Enchanted Maze?