## Squaring a triangle

Posted on: March 1st, 2014 by
5

A triangle is formed by arranging 1+3+5+7+...(2n-1) = n^2 coins as shown in the figure below.

What is the minimum number of coins that you need to move so that you can form a square that uses all the coins?

- via Algorithmic puzzles

#### 5 Responses to Squaring a triangle

If the nth row has 2n-1 coins in it you need to move 2n-2 coins. Keep the central coin in the row fixed and fill in all the holes with the remaining ones in the nth row. (The cental coin and the apex will be the endpoints of a diagonal of the square formed.

You can do faster if you make a square which is rotated 45 degrees from horizontal.

Click for Solution.

The right answer depends on your interpretation of what it means to use all the coins to form a square, but the solution I have moves $\lfloor {n\over 2}\rfloor\times \lfloor {n\over 2}\rfloor$ coins as shown in the figure below. '+' indicates a coin placed at that location and '-' indicates a coin removed from that location. '.' indicates an unmoved coin. It will be interesting to see your detailed explanation.

You said "The right answer depends on your interpretation of what it means to use all the coins to form a square" and then gave ONLY a single interpretation. If you don't give another then I imagine that in all problems you could give an "it depends.." answer. How does your answer work for the case when n = 1?

Clearly in the bottom figure of your explanation there were 5^2 original coins. i.e. n=5.
Your answer suggests that that the number of moves should be 5/2 x 5/2 which equals 6.25 moves??? You moved 6.0000 moves?