-2
$\begingroup$

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?

enter image description here

The figure above demonstrates only two possible drawings.

$\endgroup$
3
  • 1
    $\begingroup$ @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. $\endgroup$
    – hexomino
    Dec 10, 2020 at 15:21
  • 1
    $\begingroup$ This is more of a mathematical problem than a puzzle tho. $\endgroup$ Dec 10, 2020 at 15:23
  • 1
    $\begingroup$ Unfortunately, this is a question from puzzleup.com/2020/?home, a competition which explicitly the use of outside help :( Shame on you, helloworldx! $\endgroup$ Dec 17, 2020 at 8:41

1 Answer 1

8
$\begingroup$

Computer says

1256 enter image description here

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))
$\endgroup$
3
  • $\begingroup$ Your solution seems to include size 0 squares (e.g. in the last picture) ?! Nicely displayed . $\endgroup$
    – Retudin
    Dec 11, 2020 at 11:58
  • 1
    $\begingroup$ @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. $\endgroup$ Dec 11, 2020 at 12:15
  • $\begingroup$ Beautiful answer. It should be printed on a large sheet of A2 paper and framed. $\endgroup$
    – Penguino
    Dec 12, 2020 at 9:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.