## Le Monde puzzle [#1072]

Posted in Books, Kids, R with tags , , , , , , , , , , , on October 31, 2018 by xi'an The penultimate Le Monde mathematical puzzle  competition problem is once again anti-climactic and not worth its points:

For the figure below [not the original one!], describing two (blue) half-circles intersecting with a square of side 20cm, and a (orange) quarter of a circle with radius 20cm, find the radii of both gold circles, respectively tangent to both half-circles and to the square and going through the three intersections. Although the problem was easily solvable by some basic geometry arguments, I decided to use them a minima and resort to a mostly brute-force exploration based on a discretisation of the 20×20 square, from which I first deduced the radius of the tangent circle by imposing (a) a centre O on the diagonal (b) a distance from O to one (half-)circle equal to the distance to the upper side of the square, leading to a radius of 5.36 (and a centre O at a distance 20.70 from the bottom left corner):

```diaz=sqrt(2)*20
for (diz in seq(5/8,7/8,le=1e4)*diaz){#position of O
```

In the case of the second circle I first deduced the intersections of the different circles by sheer comparison of black (blue!) pixels, namely A(4,8), B(8,4), and C(10,10), then looked at the position of the centre O’ of the circle such that the distances to A, B, and C were all equal:

```for (diz in seq(20*sqrt(2)-20,10*sqrt(2),le=1e4)){
distA=sqrt((diz/sqrt(2)-4)^2+(diz/sqrt(2)-8)^2)
```

even though Heron’s formula was enough to produce the radius. In both approaches, this radius is 3.54, with the position of the centre O’at 10.6 from the lower left corner. When plotting these results, which showed consistency at this level of precision,  I was reminded of the importance of plotting the points with the option “asp=1” in plot() as otherwise, draw.circle() does not plot the circles at the right location!

## Le Monde puzzle [#1062]

Posted in Books, Kids, pictures, R with tags , , , , , on July 28, 2018 by xi'an A simple Le Monde mathematical puzzle none too geometric:

1. Find square triangles which sides are all integers and which surface is its perimeter.
2. Extend to non-square rectangles.

No visible difficulty by virtue of Pythagore’s formula:

```for (a in 1:1e4)
for (b in a:1e4)
if (a*b==2*(a+b+round(sqrt(a*a+b*b)))) print(c(a,b))```

``` 5 12
6  8
``` and in the more general case, Heron’s formula to the rescue!,

```for (a in 1:1e2)
for (b in a:1e2)
for (z in b:1e2){
s=(a+b+z)/2
if (abs(4*s-abs((s-a)*(s-b)*(s-z)))<1e-4) print(c(a,b,z))}```

returns

``` 4 15 21
5  9 16
5 12 13
6  7 15
6  8 10
6 25 29
7 15 20
9 10 17
```