kyu_3.battleship_field_validator package¶
Submodules¶
kyu_3.battleship_field_validator.test_battleship_validator module¶
Testing Battleship field validator
-
class
kyu_3.battleship_field_validator.test_battleship_validator.
BattleshipFieldValidatorTestCase
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
Testing Battleship field validator
-
test_validate_battlefield
()[source]¶ Testing Battleship field validator
Testing a method that takes a field for well-known board game “Battleship” as an argument and returns true if it has a valid disposition of ships, false otherwise. Argument is guaranteed to be 10*10 two-dimension array. Elements in the array are numbers, 0 if the cell is free and 1 if occupied by ship.
-
kyu_3.battleship_field_validator.validator module¶
-
kyu_3.battleship_field_validator.validator.
is_valid_cell
(ships: dict, field: list, cell: list, direction: str) → bool[source]¶ Validates if single cell result is valid (valid submarine or single ship cell)
- Parameters
ships – collection of valid ships (dict)
field – board game “Battleship” (list)
cell – candidate for single ship/submarine
direction – str -> horizontal, vertical, submarine
- Returns
-
kyu_3.battleship_field_validator.validator.
validate_battlefield
(field: list) → bool[source]¶ A method that takes a field for well-known board game “Battleship” as an argument and returns true if it has a valid disposition of ships, false otherwise. Argument is guaranteed to be 10*10 two-dimension array. Elements in the array are numbers, 0 if the cell is free and 1 if occupied by ship.
- Parameters
field – board game “Battleship” (2D list)
- Returns
returns true if it has a valid disposition of ships, false otherwise