-
Notifications
You must be signed in to change notification settings - Fork 0
/
polysolver.py
executable file
·60 lines (46 loc) · 1.98 KB
/
polysolver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Module de résolution du projet Poly#.
"""
from classes import *
import mesures_temps
@mesures_temps.time_measurement
def solve(challenge_data: list, solve_strategy: int = 3):
"""
Solves the given challenge data using the specified strategy2.
Args:
- challenge_data (list): A list containing the following challenge data:
- rows (int): The number of rows in the grid.
- columns (int): The number of columns in the grid.
- drone_count (int): The number of drones available.
- deadline (int): The number of turns available.
- max_load (int): The maximum weight that a drone can carry.
- products_weight (list): A list containing the weight of each product type.
- warehouses_dict (dict): A dictionary containing the warehouses information.
- orders_dict (dict): A dictionary containing the orders information.
- order_info (list): A list containing the order information. Wich are : list of items
- solve_strategy (int): An integer representing the strategy2 to use for solving the challenge data.
Returns:
- solution (str): A text containing the solution to the challenge data.
"""
if solve_strategy == 1:
import strategies.strategy_1 as strategy_1
solution = strategy_1.solve(challenge_data)
elif solve_strategy == 3:
import strategies.strategy_3 as strategy_3
solution = strategy_3.solve(challenge_data)
return solution
def save_solution(filename: str, solution: str):
"""
Saves the given solution to the specified file.
Args:
- filename (str): The name of the file to save the solution to.
- solution (str): A text containing the solution to the challenge data.
"""
import os
os.makedirs(os.path.dirname(filename), exist_ok=True)
with open(filename, "w+") as f:
f.write(solution)
return None
if __name__ == "__main__":
pass