They will run away if they are hit by a flash of light that is the same colour as them.
The flash can only reach ghosts in the front row, but the ghosts behind come forward to fill in any gaps.
Each colour flash has a limited number of uses.
Eliminate all of the ghosts using the number of flashes you have at your disposal.
The answer is as follows.
blue, green, blue, red, green,
blue, red