# Sliding balls on a 5x5 grid

You are playing a game on the following 5x5 grid. Each turn you can slide all the orange balls into one of four directions: left, up, right or down. A ball will continue sliding along a direction until it hits a wall (solid blue squares), boundary of the grid or another ball. All the balls move at once. Walls do not move. Can you get the balls to finish on the target (T) cells?

• I will be quite impressed if anyone can solve this without the use of a computer. I will reward you if you do. Mar 16, 2022 at 1:20
• Unless I've erred, it's doable even without pen and paper. Mar 16, 2022 at 1:50
• Guys are you getting sick of these puzzles? If not then I will make some more, harder ones. Mar 16, 2022 at 10:33

This is definitely a bit more difficult that the ones before, but despite OP's warnings in the comment section, there's no need for any kind of brute force. (There's an answer with a solution already, but it doesn't explain how to actually find the solution.)

Here's how to get there by retrograde analysis:

• The T at r2c2 tells us the final move must be "up".
• The T on row 1 tells us the move before cannot have been "right". Since having "up" or "down" before an "up" doesn't change anything, the penultimate move is "left".
• This means the ball that ends up at r2c2 can only have come from r4c2, which means it was in the corridor at the bottom right before that
• There's a T in that corridor, so there were two balls in there
• To get a ball into the corridor on the bottom right, there must be another ball at r5c2.

With these in the forward order, we have the following goals:

1. bring a ball to the lower left corner
2. use that ball as a stepping stone to get the other balls to the corridor at the bottom right
3. bring the stepping stone ball back to the upper right corner
4. everything will now line up perfectly for the final "left-up".

But there's a problem: if we try to use one ball as the stepping stone, and bring the other balls one-by-one, we can't just "bring the third ball": either the stepping stone ball or the one ball already in the corridor will escape. So we need to do a sneaky juggle to bring all the balls to the bottom left, which finally solves all our problems. Like so:

I didn't notice any alternative paths along the way, so this is very likely the exact same answer @noedne posted. (After double checking, it indeed is.)

• Yep, this is my exact thought process too! Not sure why OP thought a computer might be required. Mar 16, 2022 at 10:10
• Thanks for the detailed explanation and the animation. For this I am making this the accepted answer. Mar 16, 2022 at 10:28
• @justhalf as usual I underestimated the amazing problem skills of people on this site. I generated this puzzle with a computer and there is no way I would be able to solve it myself. Mar 16, 2022 at 10:30
• You're underestimating yourself too, since you're also part of "people on this site" =D A puzzle maker isn't the best person to judge the difficulty of their own puzzle, be kind to yourself :) Mar 16, 2022 at 10:55
• Nice retrograde! I started with the same thought process as well. Ultimately, while useful for confirming that it's possible, I'm not sure it was needed for finding the solution. It seems like the solution can be found by continuously doing the only thing that makes progress, instead of repeating a previous state. This may also be why it's not as hard as expected. Mar 16, 2022 at 14:36

LDRD LDRD RD LULD LDRD RDR U LDRD R URU LU

The complete solution can be found by continuously finding the only way to make progress, i.e., moving the balls into a previously unvisited state. Here is a detailed explanation of all of these progress steps:

LDRD: Move ball 1 to the bottom left.
LDRD: Move ball 2 to the bottom left.
RD: Move ball 2 to the bottom right.
LULD: Move ball 3 out while moving ball 2 back to the bottom left.
LDRD: Move ball 3 to the bottom left.
RDR: Move ball 3 to the bottom right.
U: Move ball 2 out.
LDRD: Move ball 2 to the bottom left.
R: Move ball 2 to the bottom right.
URU: Move ball 1 to the top right.
LU: Move ball 2 to the top left.

• I think you've got it! I am very impressed. Mar 16, 2022 at 3:35