[Community Puzzle] Battleship

https://www.codingame.com/training/medium/battleship

Send your feedback or ask for help here!

Created by @Eldoir,validated by @Cal-au-riz,@bbb000bbbyyy and @pac-nam.
If you have any issues, feel free to ping them.

Very interesting puzzle, but not from the obvious reasons.
The problem at hand is relatively straight forward, but trying to provide an elegant solution proved to be more challenging than I expected.

Well done for the puzzle creator for taking such a familiar problem and providing a fun and unexpected challenge

2 Likes

Thanks a lot for this very kind message! :slight_smile:
Actually, I had the idea of the puzzle and then struggled a bit to provide the solution…
My solution uses regular expressions to get the ships positions.
I guess I could be surprised seeing how players solved the problem!

1 Like

Hi !
I resolved this puzzle, very funny !!
All my tests case are ok, but i’ve got an error when i submit my solution.

The validation n° 3 is KO. I tryed a lot of configuration, but all are good. I think i don’t see a case, but can’t find it.
Can you give me an indication ?

I found the mistake, that was due the ambigous rules : we have to detect invalid boat on a cell before detecting the boats collision.

For example :

Blockquote
A1
.++++++…
+…
+…

must return error for the size of the boat (6), instead of the collision.

:slight_smile:

1 Like

Very nice puzzle, had fun solving it. Looking through other solutions I noticed an interesting thing that some people for Y coordinate of the shot take only first digit of the input and in “Touche” test case both J10 and J1 contain a ship, making it pass by lucky chance. My suggestion: move the ship in first row one line down. :wink:

1 Like