I admit that I used unnecessary floodfills cause I followed my firsy idea which was:
for each level h from 1 to 25:
pour 1 volume of water in lvl h tiles if it doesn’t leak (and mark all tiles that leak)
But indeed a top-bottom “one huge canadair” approach is even simpler and doesn’t require any floodill.
All X’s would be zero, since you are pouring water on a 3x3 stack of blocks 24 high surrounded by an outside area of zero height. All the water would run off and none would be retained. If the middle value is lower (like in your second example, where the answer would be 2), some water would pool.
I added a note that water does not leak diagonally, just to make it crystal clear.
the explanation should probably be a bit clearer, but I had a lot of fun with this puzzle and was a tough one. an extended floodfill problem. Very good idea
Agreed. Once I understand that its like spilling water into the pool and count how much water stayed inside the pool it was a lot easier for me. Like the puzzle, very nice!
Hello !
I’m really a beginner in coding and this puzzle seems to me much more difficult than the other easy puzzle. There are everything in the explanations to understand the puzzle but it’s really not that obvious at the first reading.
The lack of tags or link to understand how to solve this problem are another negative points. It’s when I read the forum that I understand that I have to used a floodfill algorithm to solve the problem and even at this stage the algorithm that I code is too slow (I tried to work with a Four-way flood fill using a queue for storage).
I think I will wait to progress to solve this puzzle but I wanted to tell you that for me it’s not an easy puzzle. If you want to let it in easy maybe write a more detailed explanation with some clues to help to built the algorithm or some link to a lesson/video who explained how to solve (just with big step) the problem or at least this floodfill algorithm
You don’t actually need floodfill here, it’s just one way to do it among several.
The solution can be very short and simple without nothing fancy.
That’s why it’s labelled easy, but it doesn’t mean the ‘simple’ method is super easy to find, you need to give it some thoughts.
About tags, I think at some point if you really want to progress you shouldn’t read them at all and approach any problem with a fresh mind, ready to try anything.
Also about giving a link to a page that explains the method, I’m not sure it’s a good idea in general. The only puzzles where I found it was legitimate is the collection of puzzle by aCat that aim at teaching classical algorithms(minimax with alpha beta pruning, MCTS, etc), and make sure you understood how to implement them.
A very interesting puzzle, and indeed I wonder whether it’s an “easy” puzzle.
I can see two possible answers:
“easy” refers to the CS methods that are required to solve the puzzle. In this case, the main method needed is flood-fill (whether explicitly implemented, or implicitly implemented as suggested above by by @pardouin, et al). Is this considered “easy” in terms of Codingame standards?
In any case I believe both explicit and implicit implementations fall under “flood fill”
“easy” refers to the algorithmical difficulty, in which case this puzzle would possibly earned a “medium”, at least compared to other puzzles in the easy category
I wish I could write more about the question of “flood vs. scans” and is it really different, but then it might hurt the experience of people who havn’t solved it yet. If anyone would like to continue this discussion in private - please
It has been hinted above: imagine a huge canadair dropping a massive volume of water at once. Then, as long as you can find a spot where water can leak outside the map/flow to a lower spot, make it leak/flow.
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