-
Notifications
You must be signed in to change notification settings - Fork 1
/
20_cpt_scumbeard_lemma_0.py
46 lines (38 loc) · 1.5 KB
/
20_cpt_scumbeard_lemma_0.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
def check_sailor_availability(required_sailors, sailor_deployments, cost_threshold):
total_cost = 0
# Check if all required sailors are found within the cost threshold
for sailor in required_sailors:
found = False
for deployment in sailor_deployments:
if sailor in deployment:
found = True
total_cost += deployment[sailor] # Add the cost of assigning the sailor
break
if not found:
return False
if total_cost > cost_threshold:
return False
# If all required sailors are assigned within the cost threshold, return True
return True
# Example usage
# List of required sailors for the ship
required_sailors = [
"Port Sailor 1", "Starboard Sailor 1", # Paired
"Port Sailor 2", "Starboard Sailor 2", # Paired
"Captain", "Cook", "Driver" # On deck
]
# Sailor deployments and the associated cost of assigning them
sailor_deployments = [
{"Port Sailor 1": 2, "Starboard Sailor 1": 2}, # Pairing costs
{"Port Sailor 2": 3, "Starboard Sailor 2": 3}, # Pairing costs
{"Captain": 1},
{"Cook": 1},
{"Driver": 2}
]
cost_threshold = 10 # Max allowable cost
# Check if sailors can be deployed within the cost limit
result = check_sailor_availability(required_sailors, sailor_deployments, cost_threshold)
if result:
print("The sailors can be deployed within the cost threshold!")
else:
print("The sailors cannot be deployed within the cost threshold.")