[Community Puzzle] Flood the World

( I created the topic, because I did not find any for this puzzle. )

While the puzzle is interesting, I think this sentence in the statement is rather misleading:
As such, the volume of water on the left is the same as on the right (6x "~").

This “6x ~” implies as if the water volume is to be calculated base on the char counts in the grid.
(Because in the provided ascii art example, the real areas of the trapezoids are NOT the same.)

After wasting an hour on a ‘char grid flood’ based solution, and after checking some test cases, now it seems to me that this approach is incorrect and we have to calculate the volumes (or areas in 2D) exactly, and taking into account the slopes as well.

EDIT: the trapezoid areas are indeed the same in the example, my mistake. But the ‘char counting’ approach still seems to be a dead end to me, because only the statement example has 45 degrees slopes, other test cases are more varied…


My approach was to split the landscape into vertical bands based on segment intersections, and find out which bands get flooded before others. I had to use recursive ‘banding’ to compute larger composite bands :stuck_out_tongue: but it worked out in the end.

1 Like

It didn’t cross my mind, but yes, it could be misleading at first. I’ve added a foot note in the description of the problem to clarify this matter.