kyu_5.find_the_safest_places_in_town package
Submodules
kyu_5.find_the_safest_places_in_town.advice module
Solution for -> Find the safest places in town.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_5.find_the_safest_places_in_town.advice.advice(agents: set, n: int) list[source]
Advice function.
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. :param agents: is an array of agent coordinates :param n: defines the size of the city that Bassi needs to hide in :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. :param agents: array of agent coordinates :param n: defines the size of the city that Bassi needs to hide in :return:
kyu_5.find_the_safest_places_in_town.print_agents module
Prints city map with agents.
Use for debug purposes only. Created by Egor Kostan. GitHub: https://github.com/ikostan
- kyu_5.find_the_safest_places_in_town.print_agents.print_map(agents: list, digit: int, expected: list) None[source]
Print map.
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
digit – 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.
Created by Egor Kostan. GitHub: https://github.com/ikostan
- class kyu_5.find_the_safest_places_in_town.test_advice.FirstAdviceTestCase(methodName='runTest')[source]
Bases:
TestCaseTesting advice and all related help functions.
- _classSetupFailed = False
- _class_cleanups = []
- test_agents_cleanup = None
- test_agents_cleanup_0(**kw)
Testing a function named agents_cleanup [with agents={(0, 0), (5, 1), (1, 5)}, n=6, expected={(0, 0), (5, 1), (1, 5)}].
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 the city boundaries. :return:
- test_agents_cleanup_1(**kw)
Testing a function named agents_cleanup [with agents={(0, 0), (1, 1), (99, 99)}, n=2, expected={(1, 1), (0, 0)}].
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 the city boundaries. :return:
- test_agents_cleanup_2(**kw)
Testing a function named agents_cleanup [with agents={(56, 27), (36, 30), (65, 40), (…8), (28, 40), (23, 30), (2, 30)}, n=10, expected=set()].
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 the city boundaries. :return:
- test_create_city_map = None
- test_create_city_map_0(**kw)
Testing a function named create_city_map [with n=2, expected={(0, 1), (1, 0), (1, 1), (0, 0)}].
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_create_city_map_1(**kw)
Testing a function named create_city_map [with n=0, expected=set()].
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_create_city_map_2(**kw)
Testing a function named create_city_map [with n=3, expected={(0, 1), (1, 2), (2, 1), (0, 0),… (2, 0), (0, 2), (2, 2), (1, 0)}].
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).
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:
Module contents
Find the safest places in town.