Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this task, you've amassed a crew of c pirates, ready to set sail and make as much money as possible (with no regard
In this task, you've amassed a crew of c pirates, ready to set sail and make as much money as possible (with no regard for your crewmates)! For every island, containing m marines and holding s money, you can decide to send over c; pirates. The money you'll earn from this is equal to: min m 8 3 s), But the pirates you send will perish in the process (As well as an equal amount of marines). Essentially you can take the ratio of pirates to marines, and multiply the available money by that amount, maxing out at the total pool of money. i There will only be no marines present on an island if the island has been previously plundered (and therefore has no money). Every day, you can decide to which islands you'd like to send pirates, and how many to each of these islands, so that you maximise the money earned (ignoring that you might end up with no crew at the end of the day). Activate Wi Every day, you can decide to which islands you'd like to send pirates, and how many to each of these islands, so that you maximise the money earned (ignoring that you might end up with no crew at the end of the day). Your task is to implement the ModelNavigator class, and the following methods: __init__(self, islands: list [Island], crew: int): Initialise, with the initial state of the islands and the number of crew you'll be taking on your journey. select_islands (self) -> list [tuple [Island, int]]: Select the islands you wish to attack, returning a list containing pairs, each pair containing the island itself, as well as how many crewmates you'll be sending to each island. select_islands_from_crew_numbers (self, crew_numbers: list[int]) -> list [float]: Similar to the last method, except rather than simply making the optimal choices for your crew numbers, you want to calculate the most money you can make with different crew configurations. You should return a list containing the amount of money you could make with the respective crew size in the input list. update_island (self, island: Island, new_money: float, new_marines: int) -> None: Called whenever an Island updates its money or marine value. island has attributes money and marines which store the original values before update. . i For this task, you may assume that all islands have a unique name, and that the ratio of marines to gold for each island remains unique throughout execution. A For this task, both select_tasks do not alter the internal state of the islands. For example, if select_islands is called, and your plan of attack is to ransack Island A for all of its money, then: * Your crew number doesn't change * Island A still has all of its marines and money. So if you call select_islands again, the return value should be the same. Intended Complexities A For this task, both select_tasks do not alter the internal state of the islands. For example, if select_islands is called, and your plan of attack is to ransack Island A for all of its money, then: . whenever an Island updates its money or marine value. island has attributes money and marines which store the original values before update. . For this task, you may assume that all islands have a unique name, and that the ratio of marines to gold for each island remains unique throughout execution. Intended Complexities Let N be the length of islands in initialisation. __init___ should have worst case complexity O(N log(N)) or less select_ islands should have worst case complexity O(N) or less, and a best case complexity of O(log(N)) or less. select_islands_for_crew_numbers has a different intended complexity for 1008/2085 and 1054 tudents. 1008/2085: worst case complexity of O(C x N), where C' is the length of crew_numbers. 1054: worst case complexity of O(N+Clog(C)), where C' is the length of crew_numbers. update_island should have worst case complexity O(log(N)) or less . * Your crew number doesn't change * Island A still has all of its marines and money. So if you call select_islands again, the return value should be the same.
Step by Step Solution
★★★★★
3.37 Rating (144 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started