The Python 🐍 problem-solving bootcamp 🚀 is starting soon. Join the second cohort now!

Can you align all of the coins on the right edge of the board?

The Python 🐍 problem-solving bootcamp is starting soon. Join the second cohort now!

Diagram of the coin positions for the problem.

Problem statement

The diagram above shows a 3 by 4 grid with 3 coins, one per row and one per column, such that the rightmost column of the grid is empty.

You are allowed to slide the coins to the columns on their right, but the coins can never leave the board (nor can they be moved back to the left). Also, you always have to move two coins at a time.

Thus, this is a legal move:

"The diagram showing an example of a legal move with some arrows."
A legal move sliding the top two coins one slot to the right.

But moving a single coin, such as in the diagram below, is not allowed:

"The diagram showing an example of an illegal move."
An illegal move that slides only one coin to the right.

Your objective is to reach this position:

"The same 3 by 4 grid containing a coin per row, with all coins on the rightmost column."
Target position.

Can you do it?

What if you extend the board two columns to the left and two rows up, and add another two coins along the diagonal?

Give it some thought!

This is an adaptation of a problem from the book “Algorithmic Puzzles” by Anany Levitin and Maria Levitin.1


Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:

  • David H., Taiwan;

Know how to solve this? Join the list of solvers by emailing me your solution!


The solution to this problem will be shared when this problem has been live for approximately two weeks, which should be in late June.

Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.

  1. This is an Amazon Affiliate link and I may earn a commission if you purchase the book. This comes at no extra cost to you. 

Take your Python 🐍 skills to the next level 🚀

I write about Python every week. Join +16.000 others who are taking their Python 🐍 skills to the next level 🚀, one email at a time.

Previous Post Next Post

Blog Comments powered by Disqus.