[Community Puzzle] Retaining Water

Great puzzle! I had fun solving it. Not sure if it;s so easy :slight_smile:

1 Like

When you wanted to solve an easy puzzle and got pain in the ass instead. I like this one.

1 Like

I wonder how to find a spot for flowing water without using a floodfill ? It would be like finding the exit of a maze without pathfinding… Weird ! No idea about this simple solution ! I’ll try the floodfill one :smiley:

I know this is a long shot due to how old this conversation is, but would like to get some ideas on the approach for this puzzle. @puma17 if you are still out there, pls let me know. Thx.

#bfs #trapping_rainwater_problem
So, one has to add the edges of the pool of bourgeoisie to the queue. Then for each of the directions up,down,right,left perform the search for the positive delta between the height of the parent cell and the child cells.
Usually I choose simple puzzles to solve them on my own with the languages I am currently learning. However in this case I was unable to do so, since the puzzle is hard.
P.S. It’s important to use priority queue, so FIFO always gives minimum at position 0.

A nice and creative puzzle. I enjoyed it.

1 Like