Draft

6 By 6 Bimaru Solver

4 of 8S_OK

Description:

Bimaru

sometimes called Battleship puzzle, Battleship Solitaire or Yubotu is a logic puzzle based on the Battleship guessing game. Solitaire Battleship was invented in Argentina by Jaime Poniachik and was first featured in 1982 in the Argentine magazine Humor & Juegos.

Rules

  1. Place a fleet of ships into the diagram. There are several different types of ships:
    three submarines ♦ two destroyers ◄► one cruiser ◄■►
  2. Each ship segment occupies exactly one cell of the diagram.
  3. Ships may be oriented horizontally or vertically and don't touch each other, neither orthogonally nor diagonally.
  4. The numbers on left/below edge of the diagram indicates how many ship segments must be placed in the corresponding row or column. Pass the clues in an array of 12 items. This array contains the clues around the clock

Can you write a program that can solve this puzzle?

Example

In this example there are one boat square and one water square are specified.
The following characters are valid:
  • bow or stern of a ship ◄ ► ▲ ▼
  • middle part of a ship
  • submarine
  • water X

Input

  • The grid is one string. Every row ends with newline separater.
    " \n \n \n ▲ \n X \n \n"
  • The clues is an array of 12 numbers. This array contains around the clock (from top to bottom and right to left).
    In this graphic, the numbers correspond to the index of the array.

Output

Return the resolved puzzle as array of six strings. The class Comparer check only count, types and positions of the ships.

Good Luck!

If you finished this kata you can use your solution as a base for the more challenging kata:
coming soon... 8 By 8 Bimaru Solver

Games
Algorithms
Game Solvers
Puzzles

Similar Kata:

More By Author:

Check out these other kata created by S_OK

Stats:

CreatedJan 30, 2020
Warriors Trained264
Total Skips116
Total Code Submissions253
Total Times Completed8
C++ Completions4
C# Completions5
Total Stars9
% of votes with a positive feedback rating75% of 6
Total "Very Satisfied" Votes3
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes0
Total Rank Assessments4
Average Assessed Rank
3 kyu
Highest Assessed Rank
2 kyu
Lowest Assessed Rank
4 kyu
Ad
Contributors
  • S_OK Avatar
Ad