Enigmatic Code

Programming Enigma Puzzles

Enigma 1718: Joe’s new property

From New Scientist #2885, 6th October 2012 [link]

Joe thinks he has found, by trial and error, a new property of triangles. He asked Penny to mark the points A along the sides of a triangle of her choice, each point to be a percentage P of the length of the side from the nearest corner. Then she had to join the points to form a second triangle and repeat the process to form a third triangle with points B. Penny found that the lengths of the sides of this third triangle were 52 per cent of the corresponding sides of her original.

What was the value of P?

[enigma1718]

3 responses to “Enigma 1718: Joe’s new property”

1. Jim Randell 3 October 2012 at 6:38 pm

Another problem that’s solved with a bit of analysis and algebra. I’m not quite sure what the general property of triangles Joe thinks he has discovered, as it seems to me that Penny has to choose her particular triangle with care (or luck) in order for the situation described in the puzzle to come about. Anyway, here’s a SymPy solution.

```from sympy import symbols, Rational, solve, Eq
from enigma import printf

# the transform takes an equilateral triangle of side 1 to side x, where:
# x^2 = p^2 + (1 - p)^2 - 2p(1 - p)cos(60 degrees) [cosine law]
# and cos(60 degrees) = 1/2, so:
# x^2 = p^2 + (1 - p)^2 - p(1 - p)
# (I won't simplify further, to give SymPy something to do)

# we apply the transform twice, so the side of a triangle goes from 1 -> x -> x^2

# so, x^2 = 52 / 100

p = symbols('p')
q = 1 - p
f = Rational(52, 100)

for r in solve(Eq(p ** 2 + q ** 2 - p * q, f)):
if not r.is_real: continue
P = 100 * r
if P > 50: continue
printf("P={P}%")
```

Solution: P = 20%.

In order for the B triangle to be similar to (in the mathematical sense) the initial triangle under the transformation given in the puzzle, it is a necessary condition that the triangle is equilateral.

The equation simplifies to:

3p² – 3p + 1 = 52/100

or:

25p² – 25p + 4 = 0

which factors as:

(5p – 4)(5p – 1) = 0

hence p = 1/5 = 20% as we want the root less than 50% (the new points are a certain percentage length from the nearest corner).

Although the text of the puzzle doesn’t make it clear, the accompanying diagram shows the smaller triangles being twisted in the same direction. I think the variation of this puzzle where the B triangle is constructed using the same technique as the A triangle, but twisted in the opposite direction (as shown in the diagram below) makes for a more pleasing puzzle as the scenario works for any triangle. And the solution is the same.

• Jim Randell 4 October 2012 at 3:04 pm

Here’s a more complete solution that doesn’t start by assuming the triangle is equilateral (although it deduces it), but instead makes use of repeated application of the cosine rule. Again it uses SymPy.

```from sympy import symbols, solve, Eq, Rational
from enigma import printf

# cosine rule, for a triangle with sides a, b, c and opposite angles A, B, C
# a^2 = b^2 + c^2 - 2.b.c.cos(A)

# initial sides of the triangle (let's assume a = 1)
(a, b, c) = (1, symbols('b'), symbols('c'))

# sides are split into: a -> pa, qa
p = symbols('p')
q = 1 - p

# after transformation the sides a, b, c -> x, y, z, where...
(a2, b2, c2, p2, q2) = (a**2, b**2, c**2, p**2, q**2)
x2 = q2*a2 + p2*c2 - p*q*(a2 + c2 - b2)
y2 = q2*b2 + p2*a2 - p*q*(b2 + a2 - c2)
z2 = q2*c2 + p2*b2 - p*q*(c2 + b2 - a2)

# final fractional reduction
f = Rational(52, 100)
f2 = f**2

# the sides are reduced proportionally after two transformations, so...
eqa = Eq(f2*a2, p2*z2 + q2*x2 - p*q*(x2 + z2 - y2))
eqb = Eq(f2*b2, p2*x2 + q2*y2 - p*q*(y2 + x2 - z2))
eqc = Eq(f2*c2, p2*y2 + q2*z2 - p*q*(z2 + y2 - x2))

# solve the equations
for (rp, rb, rc) in solve((eqa, eqb, eqc), p, b, c):
# lets have real solutions
if not(rp.is_real and rb.is_real and rc.is_real): continue
# and triangles with positive sides
if not(rb > 0 and rc > 0 and rb + rc > a): continue
printf("p={p}% a={a} b={b} c={c}", p=100*float(rp), a=float(a), b=float(rb), c=float(rc))
```
2. мата лабор 20 October 2012 at 2:23 pm

It is interesting to note that for any triangle (not only equilateral), the ratio of circumference of the 3rd triangle and the original triangle is a quadratic function of P: r = (a3+b3+c3)/(a+b+c) = 3*P^2 – 3P + 1. So, if the ratio of the circumferences is 52%, then solving this quadratic equation r=3*P^2 – 3P + 1=0.52, one gets P=0.2 (20%) and P=0.8 (80%).