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
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.