https://www.codingame.com/training/easy/retaining-water
Send your feedback or ask for help here!
Created by @Westicles,validated by @Wontonimo,@selenae and @murrayr.
If you have any issues, feel free to ping them.
https://www.codingame.com/training/easy/retaining-water
Send your feedback or ask for help here!
Created by @Westicles,validated by @Wontonimo,@selenae and @murrayr.
If you have any issues, feel free to ping them.
Itâs a good puzzle but if you donât pay much attention to the cover and go directly to the IDE, you have to guess a bit cause the Problem doesnât state much.
For example the whole structure is made of cubes, itâs never said at any point.
Also the word âpoolâ is a bit misleading, really a pool looks nothing like that.
It looks more like moutain areas with lakes of retained water than one single pool.
But despite that, it was a nice little puzzle.
For many puzzles, the tags give an additional hint. Here, the lack of a tag is a hint itself: My first (wrong) reaction when reading the statement was âHey, a floodfill in the easy category?â. Then I looked at the tagsâŚ
Nice puzzle, I liked it!
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.
LOL.
Yes, I wasted a bit of water, but conversing water was not part of the design targetâŚ
To better understand the puzzle:
What is result for 3x3 all X pool
XXX
XXX
XXX
Does water leak diagonally, what is result for:
XZZ
ZXZ
ZZZ
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.
Ok, Thanks
So result is 2 for:
XZZ
ZXZ
ZZZ
The puzzle deserves medium imo, but itâs a good one
very nice puzzle ! I dried my brain to find a correct and naturel way to fill this pool until disaster⌠congrats.
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.
Wanted a better understanding of what the test cases look like.
Sharing for anyone who finds it useful: https://codepen.io/Abrman/full/abpKbRW
This is at least medium. Or I missed a more obvious easier solution. but enjoyed solving it.
A very interesting puzzle, and indeed I wonder whether itâs an âeasyâ puzzle.
I can see two possible answers:
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
Very nice puzzle! I have enjoyed it.
This was fun! It does seem very challenging for an easy puzzle. If there is an easy solution, itâs a hard solution to find.
If someone has found a solution to this that doesnât involve flood fill, it would be nice to post a hint about it here.
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.