Supply Line
Many war games have rules concerning the supply lines. Units that can’t contact the supply source face a lot of troubles.
You should find the shortest supply line with Python.
The map used in this mission is a hex grid with a maximum size of 12x9 where each hex is numbered from A1 to L9. (A - L indicate a column, and 1 - 9 indicate a row.)
You are given three arguments: the first is the position of your unit (a string), the second is the supply depots (a set of strings), and the third is the enemy units (a set of strings). You should return the minimum number of steps from your unit to the supply depot. If you can’t set a supply line at all, return None.
The effect of the enemy hex and its adjacent hexes:
- You can’t lay the supply lines on these hexes.
- If your unit is adjacent to the enemy’s, there is no problem with the supply line.
- The supply depot on these hexes can’t be used .
Example:
supply_line('B4', {'F4'}, {'D4'}) == 6 supply_line('A3', {'A9', 'F5', 'G8'}, {'B3', 'G6'}) == 11
Input: Three arguments. The first one is the position of your unit as a string, the second one is the supply depots as a set of strings, the third one is the enemy units as a set of strings.
Output: The minimum number of steps from your unit to a supply depot as an integer (or None).
How it is used:
In war games. Searching for a path is important for movement and getting supplies.
And the idea of the adjacent hex cells is often seen as a Zone of control(ZOC).
Precondition:
- all(map(lambda x: re.match('[A-L][1-9]$', x), {you} | depots | enemies))
- you not in depots | enemies
- len(depots) > 0
- len(enemies) ≥ 0
CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.
In order to install CheckiO client you'll need installed Python (version at least 3.8)
Install CheckiO Client first:
pip3 install checkio_client
Configure your tool
checkio --domain=py config --key=
Sync solutions into your local folder
checkio sync
(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)
checkio serv -d
Alternatevly, you can install Chrome extension or FF addon
checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium
Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.
Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!
You are trying to join a pair programming session that has not started yet.
Please wait for the session creator to join.
It looks like the creator of the pair programming session closed the editor window.
It might happen accidentally, so that you can wait for reconnection.