How Many Squares on the Peg Solitaire

We have a well known peg solitaire which is not played yet as seen below: At most how many squares can you make by joining the points as exemplified below? Note: No ball (point) in the middle! so dont add that up to your sum.

• Can a single point be used in multiple squares? – Techidiot May 14 '17 at 13:20
• @Techidiot yes of course – Oray May 14 '17 at 13:21
• Thank for telling the broader name of this game. Actually I've seen this game is sold as 'brain-vita' – Always Confused May 18 '17 at 17:29

I think there are ...

... 64 squares.

Reasoning:

The question isn't very exact, but I assume that a valid square is one whose corner points are part of the initial Solitaire board. The middle peg is missing, but the lines af a square can cross the gap. The same goes of the empty spaces between the cross's arms.

We can identify each square by its topmost point (or top left point if is aligned to the vertical axis) and also by the slope of the next side clockwise. Possible squares are shown below. Squares that are not aligned along the axes or to the 45° diagonal can be reflected about the horizontal axis to give the same squares again, which is why they are multiplied by two in the tally. (1, 0): 16 squares
(1, 1): 9 squares
(2, 0): 9 squares
(2, 1): 2 × 4 squares
(2, 2): 9 squares
(3, 1): 2 × 1 square
(3, 2): 2 × 4 squares
(3, 3): 1 square
(4, 2): 2 × 1 square

total: 64 squares

• +1. I got something similar. But, didn't knew how to represent it. – Techidiot May 14 '17 at 14:27
• What I find interesting is that there are 32 pegs, half of the total squares. Maybe you can find a link? Something perhaps to do with each peg being able to form average of 2 or something like that – Beastly Gerbil May 14 '17 at 15:38
• @BeastlyGerbil: I think that's coincidence. For what it's worth, here's the distribution of squares. (The question has no no-computers tag, but I solved the problem in the graphic program I used to draw the picture, which I used to get an illustration as well as the count. Meanwhile, I've written a script top confirm my answer and I used this to find the distibution.) – M Oehm May 14 '17 at 16:11
• Come to think of it, mabe the distribution I posted in the previous comment is the intended approach, because there's a logical-deduction tag. It would be enough to test how many squares can be built from each of the points in the NW corner, say. – M Oehm May 14 '17 at 16:15
• I used Corel Draw. – M Oehm May 14 '17 at 17:18

I believe there are 56 squares possible.

16 vertical 2x2, 5 vertical 3x3, 9 diagonal 2x2, 9 diagonal 3x3, 1 diagonal 4x4, 8 knight's move border, 8 long knight's move border

Image showing some of the square types:

For reference, let the pegs be numbered as shown below.

00 01 02
03 04 05
06 07 08 09 10 11 12
13 14 15    16 17 18
19 20 21 22 23 24 25
26 27 28
29 30 31

Initially, I overlooked the presence of the {3 11 20 28} square in M Oehm's answer, so assuming some squares had been overlooked, decided to write a program to find them all. To my surprise, I got exactly the same number of squares as in that answer; but upon reading it again, saw the {3 11 20 28} square listed fairly obviously in the (3,1) category. Anyhow, here is some brute-force python code that takes about 1/16 second to list all the squares.

#!/usr/bin/env python
# Re: https://puzzling.stackexchange.com/questions/51773/how-many-squares-on-the-peg-solitaire
# In this program, given a layout of pegs, we count the number of
# squares formed by using any four of those pegs as corners.
import time

# List the x, y values of all 32 pegs, treating one of the corners as
# 0,0 and another corner as (6,6).
pegX = [2,3,4, 2,3,4, 0,1,2,3,4,5,6, 0,1,2,4,5,6, 0,1,2,3,4,5,6, 2,3,4, 2,3,4]
pegY = [0,0,0, 1,1,1, 2,2,2,2,2,2,2, 3,3,3,3,3,3, 4,4,4,4,4,4,4, 5,5,5, 6,6,6]
nPeg = len(pegX)

def dist2(m,n):
return (pegX[m]-pegX[n])**2 + (pegY[m]-pegY[n])**2

# Test if points p,q,r,s make one corner of a square
def stest(p,q,r,s):
dq = dist2(p,q)
dr = dist2(p,r)
ds = dist2(p,s)
dhi = max(dq, dr, ds)
dlo = min(dq, dr, ds)
if (dhi != 2*dlo): return False
nlo = (dq==dlo) + (dr==dlo) + (ds==dlo)
if nlo != 2: return False
return True

# Cycle through all p,q,r,s combinations, maintaining p<q<r<s
p, q, r, s = 0, 1, 2, 2        # Initial p,q,r,s tuple, -1
nSqu = 0
t0 = time.time()
while 1:
s += 1
if s >= nPeg:
r += 1
if r >= nPeg-1:
q += 1
if q >= nPeg-2:
p += 1
if p >= nPeg-3:
break
q = p+1
r = q+1
s = r+1
# If three corners work, the fourth is forced
if stest(p,q,r,s) and stest(q,p,r,s) and stest(r,p,q,s):
nSqu += 1
print 'S#{:3}  {:3}{:3}{:3}{:3}'.format(nSqu, p,q,r,s)

t1 = time.time()
print 'Elapsed seconds: ', t1-t0