Battle ships: Sunk damaged or not touched?
Description:
Task
Your task in the kata is to determine how many boats are sunk damaged and untouched from a set amount of attacks. You will need to create a function that takes two arguments, the playing board and the attacks.
Example Game
The board
|
Boats are placed either horizontally, vertically or diagonally on the board. 0
represents a space not occupied by a boat. Digits 1-3
represent boats which vary in length 1-4 spaces long. There will always be at least 1 boat up to a maximum of 3 in any one game. Boat sizes and board dimentions will vary from game to game.
Attacks
Attacks are calculated from the bottom left, first the X coordinate then the Y. There will be at least one attack per game, and the array will not contain duplicates.
[[2, 1], [1, 3], [4, 2]];
Function Initialization
board = [[0,0,0,2,2,0],
[0,3,0,0,0,0],
[0,3,0,1,0,0],
[0,3,0,1,0,0]];
attacks = [[2, 1], [1, 3], [4, 2]];
damagedOrSunk(board, attacks);
Scoring
Sunk or Damaged
Output
You should return a hash with the following data
`sunk`, `damaged`, `notTouched`, `points`
Example Game Output
In our above example..
Return Hash
{ sunk: 0, damaged: 2 , notTouched: 1, points: 0 }
Similar Kata:
Stats:
Created | Mar 20, 2017 |
Published | Mar 21, 2017 |
Warriors Trained | 11283 |
Total Skips | 4699 |
Total Code Submissions | 17448 |
Total Times Completed | 2320 |
JavaScript Completions | 638 |
Python Completions | 980 |
Ruby Completions | 158 |
C# Completions | 195 |
Java Completions | 390 |
Total Stars | 389 |
% of votes with a positive feedback rating | 91% of 471 |
Total "Very Satisfied" Votes | 406 |
Total "Somewhat Satisfied" Votes | 48 |
Total "Not Satisfied" Votes | 17 |
Total Rank Assessments | 9 |
Average Assessed Rank | 4 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |