kyu_5.find_the_safest_places_in_town package¶
Submodules¶
kyu_5.find_the_safest_places_in_town.advice module¶
-
kyu_5.find_the_safest_places_in_town.advice.
advice
(agents: set, n: int) → list[source]¶ The function should return a list of coordinates that are the furthest away (by Manhattan distance) from all agents.
- Edge cases:
If there is an agent on every grid cell, there is no safe space, so return an empty list.
If there are no agents, then every cell is a safe spaces, so return all coordinates.
if n is 0, return an empty list.
If agent coordinates are outside of the map, they are simply not considered.
There are no duplicate agents on the same square.
- Parameters
agents – is an array of agent coordinates
n – defines the size of the city that Bassi needs to hide in,
in other words the side length of the square grid :return:
-
kyu_5.find_the_safest_places_in_town.advice.
agents_cleanup
(agents, n) → set[source]¶ Remove all agents that are outside of the city boundaries. If agent coordinates are outside of the map, they are simply not considered.
- Parameters
agents – is an array of agent coordinates
n – defines the size of the city that Bassi needs to hide in, in other words the side length of the square grid
- Returns
kyu_5.find_the_safest_places_in_town.cell module¶
kyu_5.find_the_safest_places_in_town.manhattan_distance module¶
kyu_5.find_the_safest_places_in_town.print_agents module¶
-
kyu_5.find_the_safest_places_in_town.print_agents.
print_map
(agents: list, n: int, expected: list)[source]¶ Use for debug purposes only. Prints city map with agents (*) and expected results (longest distance as +) on it.
- Parameters
agents – is an array of agent coordinates
n – defines the size of the city that Bassi needs to hide in, in other words the side length of the square grid
expected – expected results
- Returns
kyu_5.find_the_safest_places_in_town.test_advice module¶
Testing advice and all related help functions
-
class
kyu_5.find_the_safest_places_in_town.test_advice.
FirstAdviceTestCase
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
Testing advice and all related help functions
-
test_agents_cleanup
()[source]¶ - Testing a function named agents_cleanup where:
agents: is an array of agent coordinates
n: defines the size of the city that Bassi needs to hide in, in other words the side length of the square grid.
The function should remove all agents that are outside of the city boundaries. :return:
-
test_create_city_map
()[source]¶ - Testing a function named create_city_map where:
n defines the size of the city that Bassi needs to hide in, in other words the side length of the square grid.
The function should generate city map with coordinates. :return:
-
test_first_non_repeating_letter
()[source]¶ - Testing a function named advice(agents, n) where:
agents is an array of agent coordinates.
n defines the size of the city that Bassi needs to hide in, in other words the side length of the square grid.
The function should return a list of coordinates that are the furthest away (by Manhattan distance) from all agents. :return:
-