## Project Euler Problem 144 – Laser light escaping an ellipse

Project Euler – problem 144 – visualization of the solution in Matlab

## Panaitopol primes – simple representation

A prime number is called a Panaitopol prime if . I stumbled upon these weird prime numbers while working on problem 291 from Project Euler.

While searching a bit about the problem I did a brute force check to find the first such primes and I found the following values:

## Linear programming #1 – Project Euler 185

I was recently faced with a very nice challenge from Project Euler – Problem 185. The idea is to find a number with a fixed number of digits by making guesses. Each time you are told how many digits you got right. By got right, I mean guessing the right digit on the right position. If you find a digit which is in the number, but on a different position, you don’t know…

There is a test case with 5 digits:

90342 ;2 correct

70794 ;0 correct

39458 ;2 correct

34109 ;1 correct

51545 ;2 correct

12531 ;1 correct

with unique solution 39542 and the difficult case with 16 digits

5616185650518293 ;2 correct

3847439647293047 ;1 correct

5855462940810587 ;3 correct

9742855507068353 ;3 correct

4296849643607543 ;3 correct

3174248439465858 ;1 correct

4513559094146117 ;2 correct

7890971548908067 ;3 correct

8157356344118483 ;1 correct

2615250744386899 ;2 correct

8690095851526254 ;3 correct

6375711915077050 ;1 correct

6913859173121360 ;1 correct

6442889055042768 ;2 correct

2321386104303845 ;0 correct

2326509471271448 ;2 correct

5251583379644322 ;2 correct

1748270476758276 ;3 correct

4895722652190306 ;1 correct

3041631117224635 ;3 correct

1841236454324589 ;3 correct

2659862637316867 ;2 correct

While the small case could be tackled using a pure brute force approach (only ) cases to check, the second case becomes intractable. Looping through all cases would take ages. One could try genetic algorithms or other algorithms based on randomness. Recursive approaches are also possible.

There is however a way to express this problem which makes it solvable right away using a linear programming solver: that is an algorithm which finds valid solutions given some constraints. How do we find these constraints? There are essentially two types of constraints in our case:

- each of the positions of the result contains one digit from 0 to 9
- in each of the guesses given above we have a fixed number of correct digits

## About Problem 587 – Project Euler

I started looking again at some problems on the Project Euler site. It’s not often that I manage to solve a recent problem. Below are a few hints about the math needed to provide an answer to problem 587.

I’ll not repeat the statement of the problem here, so please read it by following the above link. The idea is to find the ratio of the areas of some triangular shapes made of two segments and one circle arc. The breakdown of the problem is the following:

- Note that the size of the square does not matter, since we need the result as a ratio, so we can consider that the square has side equal to 1. First note that the L-shape in the corner of the triangle has area equal to . We’ll need this in the end, to compute the ratio.
- Secondly, the shape whose area we need to compute can be decomposed into a right-angled triangle and a complement of a part of the circle. In order to have precise information about these shapes we compute the intersection of the line y=x/n and the circle (x-0.5)^2+(y-0.5)^2=0.25. It is possible to find the value explicitly.
- Once we have the coordinates of the point of intersection we can compute the area of the triangle. The area of the rounded part which remains is the difference between a rectangle and the circle portion PQON. In order to do find this difference it suffices to find the angle PSQ.
- Once the mathematical part is done, the programming job is not that tough, since the numbers involved are not that high. I managed to write a Matlab solution in no time.

## Putnam 2016 – A4

**Problem A4.** Consider a rectangular region, where and are integers such that . The region is to be tiled using tiles of the two types shown below

(The dotted lines divide the tiles into squares.) The tiles may be rotated and reflected, as long as their sides are parallel to the sides of the rectangular region. They must all fit within the region, and they must cover it completely without overlapping.

What is the minimum number of tiles required to tile the region?

## Some of the easy Putnam 2016 Problems

Here are a few of the problems of the Putnam 2016 contest. I choose to only list problems which I managed to solve. Most of them are pretty straightforward, so maybe the solutions posted here may be very similar to the official ones. You can find a complete list of the problems on other sites, for example here.

**A1.** Find the smallest integer such that for every polynomial with integer coefficients and every integer , the number

that is the -th derivative of evaluated at , is divisible by .

**Hints.** Successive derivatives give rise to terms containing products of consecutive numbers. The product of consecutive numbers is divisible by . Find the smallest number such that . Prove that does not work by choosing . Prove that works by working only on monomials…

## Withings Activité – each step counts…

This post is not about math… It’s about a watch which is elegant, smart and a good activity motivator. The Withings Activité is all the above and more. Apparently this watch is on a market for quite a while now, but I didn’t hear about it until recently (via a Facebook add, the irony… I usually despise ads). What caught me was the nice quality design and the promise that it can do more than just tell time.

So what exactly can this watch do?

- tells time via an analog display
- has a silent vibrating alarm
- counts your steps
- shows progress towards the daily goal
- monitors sleep
- can monitor running and swimming
- battery lasts 8 months (that’s forever compared to other fancy smartwatches out there)