Problem 2004. BattleShip - Petty Officer (Level 2)

Games Magazine Battleships is a logic puzzle to find the Fleet given some map information and the number of Ship cells in every column and row. The fleet is made of a Battleship(4), two Cruisers(3), three Destroyers(2), and four Submarines(1). Thus the total filled cells is 20.
The Seaman Level is the simplest and can be solved by direct evolution of current condition. The Petty Officer Level requires just a pinch more effort to solve.
Map information contains Water(0), Subs(1), Middle of a ship(6), Unknown(7), and the Aft(rear) of a ship. Ship going Up(2), Down(3), Left(4), and Right(5).
Ships have no diagonal or UDLR adjacency. The best way in Seaman to deal with Midship segments is to determine where it can not go to determine an orientation.
The map is ringed by zeros to make m a 12x12 array.
Input: m,r,c; m 12x12 of map values, r(12,1) of row sums, c(1,12) of col sums
Output: b; A binary 12x12 array
r=[0 2 0 2 2 2 3 2 3 0 4 0]';
c=[0 4 0 3 1 3 1 4 0 1 3 0];
m b
000000000000 000000000000
077757777770 000011000000
077777777770 000000000000
077777777770 000100010000
077777777770 000100010000
077777777770 010000010000
077777777770 010000010010
027777777760 010000000010
077777777770 000101000010
077777777770 000000000000
077777477770 010001100100
000000000000 000000000000
1) Initialize processing array based upon input matrix.
2) Implement a cycling check of driven array changes
3) Quick Test of Change every single Unknown serially
4) Evolve and check if complete solution created

Solution Stats

80.0% Correct | 20.0% Incorrect
Last Solution submitted on Oct 01, 2020

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author302

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!