Question
Imagine a triangle of coins on a table so that the first row has one coin in it and the second row has two coins in it and so on. If you can only move one coin at a time, how many moves does it take to make the triangle point the other way?


For a triangle with two row it is one, for a triangle with three rows it is two, for a triangle with four rows it is three.

For a traingle with five rows is it four?

Answers

Answer

It takes 5 moves to make the triangle with 5 rows point the other way.

0 = a coin that has not been moved.
X = the old position of the moved coin
8 = the new position of the moved coin.

________X
_______X X
____8 0 0 0 8
_____0 0 0 0
____X 0 0 0 X
_______8 8
________8


For traingle of any number of rows, the optimal number of moves can be achieved by moving the vertically symmetrical coins i.e. by moving same number of coins from bottom left and right, and remaining coins from the top.


For a triangle with an odd number of rows, the total moves require are :
(N2/4) - (N-4) Where N = 4, 6, 8, 10, ...

For a triangle with even number of rows, the total moves require are :
((N2-1)/4) - (N-4) Where N = 5, 7, 9, 11, ...

Thanks to Alex Crosse for submitting above formulas.   Your Comment






Search
Can you Answer!!
  • Q What are the different operators in C++?
  • Q Jpa job roles and responsibilities? Jpa job duties?
  • Q Expand NCSTC
  • Q What is string interpolation in Scala?
  • Q Will global warming (from the greenhouse effect) result in an increase in mosquito-borne diseases?
  • Q What to expect with veneers
  • Q Explain the relationship between entity, entity class, and entity instance?
  • Q Can svg images be made responsive to user actions?
  • Q What would your first 30, 60, or 90 days look like in this role?
  • Q From what http messages are made?
  • Q The pregnancy enlargement of gingivae is a result of: