[Community Puzzle] Longest coast

https://www.codingame.com/training/easy/longest-coast

Send your feedback or ask for help here!

Created by @Ayza,validated by @FredericLocquet,@InSync and @Darazdeblek.
If you have any issues, feel free to ping them.

Testcase 4 is tricky, it counts not only surrounding water but also inner lakes

true, surrounding may not be the best word to describe the goal. if you have any better suggestions please let me know. (alternatively I could mention that water inside the island counts)

coast, coastline, seashore waterside, waterfront…

for your selection

1 Like

Thanks, should be better now. changed the title aswell.

Why does test 5 output a coast length of 10, I am (and my code) counting 15…

These are the positions of the blocks belonging to the 3rd island (in format y,x):
[[3, 5],[4, 5],[4, 6],[5, 6],[4, 4],[5, 4]]

Count all the water blocks surrounding them excluding blocks you already counted previously, and you’ll see that they total up to 10.

Don’t count the corners, just count the EWNS contiguous borders.

nice twist on the classic islands bfs problem. Makes you work a bit more for the answer by testing that you don’t double-count coasts in your bfs, and making a sort on multiple properties.

1 Like

It’s a discrete derivation problem.

Large Archipelago.
“when encountering a block that you haven’t visited”
It’s a bit boring, I was defining an whole island when i met a new block. Seems its not the way to proceed.
I have the good number of water around, but not the good position of the island (56 88 instead of 51 88)

Hello,

I’m having problems with the Validator 1 test, but pass all the others.
Can someone find me good test case so I can debug what is wrong plz?

You can send me your code, I’ll send back what’s wrong.

Hi,
May I have not took the problem in good way, but on my approach it seems more a medium puzzle.
The point of difficulty is to maintain the list of islands in the right order when these are connecting far from their first discovery…