Project Euler - Magic 5-gon Ring (problem 68)

300 Views Asked by At

The problem's description is found here, but I screen shot it for your convenience.

I have been attempting to solve problem, but no luck so far.

I am actually not looking for a solution but rather an explanation of the rules of the problem.

What I fail is to comprehend what constitutes a viable set - to me it seems that any three distinct nodes can constitute a viable set.

Also, I am unable to identify any significant relationship between the sets that together form a solution.

What pattern is there to distinguish valid pathways from invalid and what relationship is there between members of a solution set?

Thank you for taking the time to reach here :)

2

There are 2 best solutions below

0
On

The $2n$ nodes shall be filled with the numbers $1,2,\ldots, 2n$. Then for each line of three nodes, add the values of the nodes. This sum should be the same for all $n$ lines.

0
On

Answer posted as guidance for solving the problem on paper - and does not give the solution.

Personally, I found the guidance on this problem, well ... confusing. The first solution made perfect sense, then the other example solutions did not seem to follow any logic (that I could humbly determine).

So I stuck with the first example and the simple rules:

  • Start with the lowest value on the outer ring
  • Work clockwise

Given, each value on the inner ring is used twice, the sum of entire ring must be 2 * (1+2+3+4+5)+7+8+9+10 = 70. Meaning, each triplet must be equal to 14 (as $\frac{70}{N\_LINES}$).

As we want the highest value, the first node placed on the outer ring must be 6, as 1-5 will occupy the inner ring and we begin with the lowest value and work clockwise. This line will continue with the highest available values (which sum to 14), 5 and 3 for the triplet $[6,5,3]$.

Since we're working clockwise, it only makes sense to use 10 as the next outer value. As each line must equal 14, 10 + the already placed 3, means the next inner value is 1.

Carry on this logic, and you'll solve it on paper!