# What is the best algorithm to flip a triangle?

I'm trying to flip a triangle like this in the following image:

there are two constraints in flipping it:
1- flip it with the minimum circles moves
2- the circles is sliding from a place to another and can't jump over another circle.
3- the circle can move vertically or horizontally
4- the circle can move any number of steps horizontally or vertically and it will considered only one move, but it shouldn't jump over any other circle in its moving path.

The triangle can be of any size.
Can anyone tell me about an algorithm that can make this job e.g. divide and conquer or greedy algorithms

• Please edit your question to define more precisely what kinds of moves are allowed. What directions is a circle allowed to slide in? How far can a circle slide in one move? What's the context where you encountered this task?
– D.W.
May 10 at 22:05
• Have you found the minimum number of moves when the triangle contains 1, 2, 3 or 4 0s on its bottom line? Can you observe some pattern? If you have found an answer, you can answer your own question. yesterday