Problem 2005. BattleShip - Seaman (1) thru Admiral(6) : CPU Time Scoring(msec)
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.
This Challenge is to complete three full sets of Battleship in minimal time.
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
Scoring: Total Time (msec)
Example:
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
Algorithm:
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 5) Robustly recursively check all potential Battleships, Cruisers, Destroyers, Subs
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers3
Suggested Problems
-
2404 Solvers
-
193 Solvers
-
226 Solvers
-
700 Solvers
-
5457 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!