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
Solution CommentsShow comments
Problem Recent Solvers4