# How many shapes can you form with squares? [closed]

There is a 6 by 6 dot-grid. You will draw two squares by joining the dots.

• The squares cannot have common dots/points or areas.
• Rotations or reflections of a drawing are considered distinct.

In How many ways can this drawing be accomplished?

The figure above demonstrates only two possible drawings.

• @zixuan You can't make a square out of just any four points (for example, if you take 3 points from the top row and one from the bottom). Also the squares are not allowed to intersect, if I understand correctly. Dec 10, 2020 at 15:21
• This is more of a mathematical problem than a puzzle tho. Dec 10, 2020 at 15:23
• Unfortunately, this is a question from puzzleup.com/2020/?home, a competition which explicitly the use of outside help :( Shame on you, helloworldx! Dec 17, 2020 at 8:41

Computer says

1256

Code

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import colors
import shapely.geometry as sg

# plotting
col = it.cycle(colors.CSS4_COLORS)
plt.figure(tight_layout=True)
def ps(Sq,c):
plt.plot(*Sq.exterior.xy,"-",color=c,linewidth=3)
plt.fill(*Sq.exterior.xy,"-",color=c,linewidth=3,alpha=0.5)

# grid
P = np.array([[sg.Point(i,j) for j in range(6)] for i in range(6)],"O")
# all squares on grid
S = [sg.Polygon([P[s+y,s+x-r],P[s+y-r,x],P[y,x+r],P[y+r,s+x]])
for s in range(1,6) for y,x,r in it.product(*map(range,(6-s,6-s,s)))]

# pairs
sol = []
for j,S1 in enumerate(S):
plt.subplot(7,15,j+1)
ps(S[-5],"white")
ps(S1,"black")
for i,S2 in enumerate(S):
if not S1&S2: # no overlap
ps(S2,next(col))
if j<i: # no double counts
sol.append((S1,S2))
plt.axis("equal");plt.box("off");plt.axis("off")
plt.show(block=False)

print(len(sol))

• Your solution seems to include size 0 squares (e.g. in the last picture) ?! Nicely displayed . Dec 11, 2020 at 11:58
• @Retudin It's actually 0 squares, not size 0 squares. I display each square once as the gray reference, even if there happen to be no possible partners. Dec 11, 2020 at 12:15
• Beautiful answer. It should be printed on a large sheet of A2 paper and framed. Dec 12, 2020 at 9:49