// you’re reading...
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)
Loading ... Loading ...

Project Euler Solutions

Project Euler 173

Problem Description

We shall define a square lamina to be a square outline with a square "hole" so that the shape possesses vertical and horizontal symmetry. For example, using exactly thirty-two square tiles we can form two different square laminae:

With one-hundred tiles, and not necessarily using all of the tiles at one time, it is possible to form forty-one different square laminae.

Using up to one million tiles how many different square laminae can be formed?


This solution handles this problem and problem 174 as well.

Although this much work really isn’t necessary, it’s interesting that it provides the resources to investigate certain conditions. The problem only requires a count and to that end something simple, as follows, would suffice:


Runs < 2 seconds in Python.

n = 1000000
nx = [0]*(n+1)
for h in range(1, n/4):
  nt = h*4 + 4
  sumx = nt
  while sumx <= n:
    nx[sumx] += 1
    nt = nt + 8
    sumx = sumx + nt
print "Answer to pe173 & pe174 =", sum(nx), sum([nx.count(i) for i in range(1,11)])


See problem 174.


No comments yet.

Post a comment