# Colored balls in a 4x4 grid

Puzzling Asked on December 19, 2020

Colored balls are placed in a 4×4 grid. A move consists of swapping two adjacent (horizontally or vertically) balls. What is the least number of moves required to form 4 connected components*, one for each color in the following grid?

*Here a connected component is a collection of balls of the same color, such that there is a path of horizontal or vertical steps from any ball to any other ball.

Correct answer by Retudin on December 19, 2020

Two pretty solutions with mirror and rotation symmetric outcomes:

Note on optimality:

Answered by Paul Panzer on December 19, 2020

Since the question does not request that all of the balls are part of a component, I will go with 3 moves.

YGBR
GBGR
RYGY
GBRR

to

YGBR
GYGR
RBGY
GBRR

to

YYBR
GGGR
RBGY
GBRR

and

YYBR
GGGR
RBGR
GBRY

Compenents are

YY B R
GGG R
R B G R
G B RY

If more than 4 components are allowed, the last step is not necessary, and the total count is 2.

Answered by SJuan76 on December 19, 2020

This can be done in

which I believe is pretty close to optimal, if not already.

Denoting the four colors as R, G, B, Y respectively, the initial state is

Y G B R
G B G R
R Y G Y
G B R R

Now,

Then,

Finally,

Answered by Bubbler on December 19, 2020

## Related Questions

### An Evil Cartesian Psycho

0  Asked on July 5, 2021

### Help Puzzling grow, you can… or just make a Riley

1  Asked on July 5, 2021

### What is the name or author of this tangrams-like packing puzzle?

1  Asked on July 4, 2021

### The wrapping machines of Santa

2  Asked on July 4, 2021

### My Latest Password

1  Asked on July 4, 2021

### A 5-out-of-9 shading Nurikabe

2  Asked on July 4, 2021

### Embassy Park – A Grid Deduction Puzzle

1  Asked on July 4, 2021

### 3D Tapa – Count to Five

1  Asked on July 3, 2021

### A rectangle, a circle, and a triangle are drawn on a plane

4  Asked on July 3, 2021

### Making 100 starting with two 1s

2  Asked on July 2, 2021

### Swapping 6 queens in a 4×4 grid

3  Asked on July 2, 2021

### 5 points on a ball, divide the ball into 2 halves so that one half as exactly 4 points

6  Asked on July 1, 2021

### Cut the string!

1  Asked on June 30, 2021 by rahim

### What is a Complete Word™?

3  Asked on June 30, 2021 by jack-pettinger

### My prefix is a lie

1  Asked on June 30, 2021

### A family of seven!

1  Asked on June 30, 2021

### Decoding a mystery sequence of falling boulders

0  Asked on June 29, 2021 by geotheory

### Meat, metal and Mediterraneans

1  Asked on June 28, 2021

### What Am I? Alive Without Breath

1  Asked on June 28, 2021 by the-jokester

### God, I’m so bad with names

3  Asked on June 28, 2021 by spandan

### Ask a Question

Get help from others!