[Community Puzzle] Battleship Solitaire - Puzzle discussion

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @VizGhar,validated by @Timinator,@cedricdd and @Eulero314.
If you have any issues, feel free to ping them.

Trying to solve in C++.

Seems that I have a misunderstanding… Trying the 2d given case, I have the following output (outputed solution seems fine to me) =>


Sortie standard :

xxxxxx
xxxxxx
xxxxxx
<#>xxx
xxxxxx
xxxxxx

Informations :

Invalid solution :(
Cell [0, 3] conflicts with the initial configuration.
Cell [1, 3] conflicts with the initial configuration.
Cell [2, 3] conflicts with the initial configuration.
Cell [0, 3] is not filled.
Cell [1, 3] is not filled.
Cell [2, 3] is not filled.
Expected 3 ship cells in row 3, got 0.
Expected 1 ship cell in column 0, got 0.
Expected 1 ship cell in column 1, got 0.
Expected 1 ship cell in column 2, got 0.
The number and size of ships used does not match the expected fleet.


Note: my solution passes the 1rst test case (with ‘o’s chars and ‘x’s water chars only). A problem with the chars ??

Output

size lines of size characters: the final resolved board. Each character must be one of:

    x : water cell.
    o : ship cell (any part of any ship, regardless of its size or shape).

As stated in the Output section, any part of any ship must be a o, therefore the expected output for test case 2 is:

xxxxxx
xxxxxx
xxxxxx
oooxxx
xxxxxx
xxxxxx

Cheers.

Very Fun Puzzle, solving in logic only was a nice chalenge !!
Please continue like I’m quite fan of your large collection of interesting puzzles.
For info, as of today logic based record : 2.1ms max time for IDE test cases (in Pyhon) :stuck_out_tongue: logic rules any backtrack I think.
@Timinator you said in contributions that you got it done in pure logic, was it in python also?

1 Like

Yes, it is in Python. If you run my currently published solution, you’ll see unresolved cells = 0 for each test case right before asking Algorithm X to search. I left all my Algorithm X code in place for any potential future discussion as I thought the matrix setup was interesting, especially the mutual exclusivity. It also makes it easy to remove bits and pieces of logic and see how much searching then needs to be done.

Outstanding times! Maybe you can help me out with my logic on Magnets! (still on the contribution page). I can solve all logically except Validator 9: Impossible 2.

And don’t forget about Nurikabe! I don’t normally put too much thought into optimizing my logic (I should start!), but I couldn’t solve the bigger Nurikabe grids without some serious thought about logic optimization.

Hi Timinator,
I started nNurikabe but I paused it for the moment. The logic is quite tricky to build there. The 2x2 sea square is certainly the trick with the most impact but not obvious coding so far.
Didn’t statrt mgnets yet.
At the moment I’m on colors, the logic side can be pushed there but I’m still checking it resolve all…

1 Like

It’s better to continue the discussion of other puzzles in their respective threads :wink:

1 Like