Question
***python 1) You want to check if there is any fish in the input tank which Frenzy can eat. Modify the function any_smaller() so that
***python
1) You want to check if there is any fish in the input tank which Frenzy can eat. Modify the function any_smaller() so that it takes the tank (2D list) as the first input, the level of Frenzy (int type) as the second input. It returns True if there is any fish in the tank which Frenzy can eat, and return False otherwise
>>> any_smaller([[5,4,3],
>>>>>>>>>>>>>[6,7,8],
>>>>>>>>>>>>>[4,7,8], 3)
False
>>> any_smaller ([[5,4,3],
>>>>>>>>>>>>>[6,7,8],
>>>>>>>>>>>>>[4,7,8], 4)
True
2)You want to check if Frenzy can eat all the fish in the input tank. Modify the function all_smaller() so that it takes the tank (2D list) as the first input, the level of Frenzy (int type) as the second input. It returns True if Frenzy can eat all other fish in the tank, and return False otherwise.
>>>>all_smaller([[5,4,3],
>>>>>>>>>>>>>[6,7,8],
>>>>>>>>>>>>>[4,7,8], 8)
False
>>>>all_smaller([[5,4,3],
>>>>>>>>>>>>>[6,7,8],
>>>>>>>>>>>>>[4,7,8],10)
True
3) Assume that the search range of Frenzy is a 22 window. That is, Frenzy can eat maximum 4 fish in any square of size 22 of the tank, and gain experience points equal to the sum of the levels of the fish in the 2 2 square range. However, Frenzy will be eaten if any of the four fishs level is larger or equal to its level. You want Frenzy to gain as much experience as possible, but also avoid being eaten. Modify the function max_exp() so that it takes the tank (2D list) as the first input, the level of Frenzy (int type) as the second input. It returns the maximum experience Frenzy can gain in that tank without being eaten. For example, in the tank below, Frenzy is a level greater than all the fish in the tank so by eating the fish in square [[7,8],[7,8]], he can maximize his experience points, which is 30.
>>>max_exp([[5,4,3],
>>>>>>>>>>>[6,7,8],
>>>>>>>>>>>[4,7,8], 9)
30
In the other tank below, the square [[7,7],[6,5]] contains the maximum experience points, but because Frenzys level is only 7 he cant choose this square and has to pick the [[5,5],[5,5]] square instead.
>>>>>>>max_exp([[7,7,7,7,7],
>>>>>>>>>>>>>[1,6,5,5,5],
>>>>>>>>>>>>>[9,7,5,5,1]], 7)
20
You can assume that the first input for this function is always a 2D list (the tank), and the second input is always an int (Frenzys level), so you dont have to worry about invalid input.
Step by Step Solution
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