# How to solve this Loopy puzzle efficiently with little backtracking?

I would like to solve this Loopy (Cairo) puzzle:

But I would like to do so with as little backtracking as possible. By this I mean that I want to have at most one pending guess at a time; I do not want to make any further guesses if I have already made one that has not yet been disproven. I believe it is possible using some local patterns, but either I have not found enough local patterns to assist me, or it is in actual fact harder to do so than to just guess more and do more backtracking. I did manage to solve this puzzle but it took me a long time to find suitable search paths that only had one pending guess at any time.

To put my question another way, what is the shortest purely logical solution you can come up with to find the solution to this puzzle and prove that it is unique?

Here is one point at which I could not proceed locally:

I then used 1-guess backtracking to obtain the following (i.e. in each of the 3 places removing those edges would lead to a contradiction):

• I agree with Bobble. I solved it without much trouble (and no backtracking at all), so it would be best to give us a picture of the point where you think backtracking might be needed. – Jaap Scherphuis Nov 6 '20 at 17:18
• @bobble: Thank you for your comment. I forgot that we should not rely on external links. I have updated my question. – user21820 Nov 7 '20 at 1:18
• @JaapScherphuis: I have included the point at which I could not proceed locally, as well as what I did get using backtracking. Thanks! – user21820 Nov 7 '20 at 1:18
• Would a next step be sufficient for an answer, or do you want a full logical solution? – bobble Nov 7 '20 at 1:41
• Something that isn't answer-worthy: it's very important to always mark any lines that can't be used as such by clicking them away. Then you can see which lines are available. You don't appear to have done this. – bobble Nov 7 '20 at 2:25

Okay, so I solved the whole puzzle :) I will use this specific puzzle to showcase several interesting deductions. Each picture will show one deduction I consider non-trivial, and in between pictures I will make trivial deductions. In this post, "trivial" deductions are:

• if a cell has all its borders spoken for (e.g. a 1 that has one border shaded), I remove all other borders
• if a cell has only the minimum number of borders left (e.g. a 3 that has 2 borders removed), I mark all other borders as used
• if a line has only one other line it could extend to, I extend it
• if a border would create a fork in the loop, I remove it
• if a border would close the loop, I remove it

Each deduction will have its area circled. Some also have arrows pointing to important lines. If you want to figure out the deductions by yourself, only click on the first spoiler of each pair to see where the deduction will be. In my explanations, a digit refers to a clue number, and a spelled-out number refers to a quantity.

Some terminology that I use here:

• "sides" and "borders" are used interchangeably to refer to a single clue-cell's borders
• "walls" and "lines" are generic terms for a confirmed section of loop
• "corner" is a spot where multiple possible borders meet
• "naked" sides are those which must be used together for connectivity purposes - for example, any of the outside-border sides

On to the deductions!

Step 1:

The deduction:

The 4 can only have 1 border unused. That border has to be one of those adjacent to the line coming in from the 3; if both of the adjacent borders are use that creates a fork in the loop. Therefore every border not adjacent to the 3's line must be used

Step 2:

The deduction:

This is similar to the previous deduction. The 3 has to use one, and only one, of its remaining sides. No matter which side is used, the 3's side will act the same as the all-important size form the previous deduction. Therefore all sides of the 4 which are not adjacent to the 3 must be used.

Step 3:

The deduction:

Here the same deduction can be used twice. Both of these 2s need to use exactly one of the two remaining sides. Both sides will use the "middle" corner. The line not bordering the 2, but connected to the "middle" corner, must be used to avoid using both remaining borders of the 2.

Step 4:

The deduction:

This is a similar deduction to the one before. One, and only one, of the 1's remaining sides must be used, so the outside side connecting to the middle "corner" must be used. I've marked it with an arrow for clarity. Since it is used, then we can apply the reverse of this deduction to the 3. One, and only one, of the 3's remaining sides must be used - and the side we colored in must be the outside "corner" connector, since only one outside side can be used. (If both are used, then the 3's sides would create a fork)

Step 5:

The deductions (two related ones):

There are two "naked" walls on one side of the 3 that must be used together, and then three others. If the "naked" walls aren't used, then a fork is created with the other three walls and the line from the 1. Therefore the "naked" walls are used. Now only one wall more can be used. If the wall that the arrow is pointing to is used, then the line from the 1 cannot be extended. Therefore that wall is not used.

Step 6:

The deductions (two related ones):

There are two lines leading in to the 2. Extending either will use up one of the 2's allotted sides. That's all the sides that can be used, so the line with an arrow pointing to it cannot be used. Given that that side is not used, the two borders for the neighboring 2 are now "naked" and must be used together. Except they can't be, since one side of that 2 is already used. So neither of those borders can be used.

Step 7:

The deduction:

The circled 3 has two "naked" sides. If they aren't used, there are only two sides left, which is too few. Therefore the "naked" sides are used.

Step 8:

The deductions (two related ones):

The left-side circled 1 has two "naked" sides. They can't be used, as two sides is too many for a 1 to use. The right-side circled 1 has a line leading into it. If any of the sides not adjacent to that line are used, then the line has nowhere to extend to. So all of the non-adjacent sides are unused.

Step 9:

The deductions (two related ones):

The left-side circled 3 has only two ways to use exactly three sides: the top "naked" two and the far-right side, or the the bottom "naked" two and the far-right side. From this it is clear that the far-right side must be used, and the side leading in to both "naked" ones from the left must be use. The right-side circled 4 has a line leading in to the top and the bottom (because at least one of the two remaining sides for the lower 3 must be used). Only one of each border adjacent to those coming-in lines can be used, to prevent a fork in the loop. To use three borders, then, the only non-adjacent side must be used.

Step 10:

The deduction:

The line leading in to this bottom section (black arrow) must go up at some point to connect to the rest of the loop. To go up, the line that is being pointed to by the red arrow must be used.

For completion, the solution:

It seems you were asking for a logical solve from your second picture, not your third picture. Below I present such a solve. This time I skip all trivial deductions, as well as deductions that I covered in the above pictures.

Step 1 (again):

The deductions (two related ones)

The circled 2 has only three sides available, and a corner between two of those sides has a line leading into it. Only one border on either side of such a line can be used, so the one non-adjacent border must be used. Additionally, the leading-in side cannot bend away from the 2, as this would remove both of the 2's borders around that corner, so the below 2 cannot have its top side used

Step 2 (again):

The deduction:

The 2 can use either its two "naked" sides together, or its other two sides. Either way, the 4 must use its bottom 3 sides.

Step 3 (again):

The deductions (two related ones):

Both the 1 and the 4 have the same deduction, covered above: the "middle corner" must have a side leading out of it, for connectivity. This also means the non-"naked" sides of the 2 from the last deduction must be used, instead of the "naked" ones.

Step 4 (again):

The deduction:

Neither the 2 nor the 3 can use their shared corner all by themselves. If the 2 did, then the 3 would be forced to make a fork, and if the 3 did, then the 2 would only have one side left to use. Therefore the 2 must use its one non-corner side and the 3 must use its two "naked" sides.

Step 5 (again):

The deduction:

If the 4 doesn't use its "naked" sides, then it will have only three sides left. Therefore it uses its "naked" sides.

Step 6 (again):

The deduction:

If the 2 uses its bottom side, then there are three ends in the circled area. Three ends cannot connect to each other for a loop. Therefore the 2 does not use its bottom side.

From there the solution is trivial.

If any of that is too confusing, feel free to ask for clarifications in the comments.

• Thanks! If you don't mind, can you also say something about the position I had before those 3 one-guess-backtracking deductions? After those 3 deductions things are easier, but my main problem was that I did not see a way to obtain those 3 deductions without backtracking. – user21820 Nov 7 '20 at 7:46
• By the way, my solution path after those 3 deductions is almost identical to yours. So it is really only those 3 that seem hard to me. – user21820 Nov 7 '20 at 7:51
• @user21820, does the edit answer your question? – bobble Nov 7 '20 at 18:32
• Yes it does! I realize what I was missing now, and the biggest was "the 4 must use its bottom 3 sides". Thanks! – user21820 Nov 7 '20 at 18:56
• You did use this kind of deduction several times in your answer, but you just expressed things differently (like "the line that comes here must go out at some point"). Don't consider this as a criticism, I just wanted to stress that you could introduce a general rule that you could refer to in order to accelerate things. Anyway, great answer, I would not have been brave enough to write everything down like this. – xhienne May 20 at 21:47