[Community Puzzle] A mountain of a mole hill

All test cases and validators share an unstated constraint that all fences are close-ended. Shall I add that as a constraint or do you have any other suggestions?

I disagree. This IS an ā€œeasyā€ challenge, but it does still require a little thinking.

Flood fills are slow and unnecessary, but fun.

Remember that everything outside of the grid is also ā€œoutsideā€ of the garden. So, as you read the line from left to right, what conditions make you become INSIDE the garden? Passing some vertical fencing ā€™ | ā€™ of some kind, yes? What happens if you pass a second vertical fence? a third? a fourth?

Identifying vertical fencing can be done per line - as they are read from the input.

Consider what horizontal fence sections ā€˜Ā±----+ā€™ actually mean ā€¦ how you understand these is important. Sometimes they mark a boundary between the inside and the outsideā€¦ sometimes they donā€™t. When do they behave like vertical fences? ; )

Time spent away from the computer, thinking about how the problem can be simplifiedā€¦ and perhaps doodling some fences on a napkinā€¦ almost always pays off in faster, simpler and more efficient code ; )

Great puzzle I had a lot of fun, tyvm!

I agree actually, I mean i solved it but it shouldnā€™t be ā€œeasyā€,ā€œmediumā€ would do better

1 Like

yeah this is three years old, but I had been coming back and forth from this puzzle for months and this hint finally made it click for me. Which is crazy because of how many other puzzles I had solved by adding a layer of padding around the ā€œimage.ā€ Thanks for the hint.

1 Like