# [Community Puzzle] Longest coast

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

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â€¦

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â€¦