Answered You can hire a professional tutor to get the answer.

QUESTION

The evil Ice King has sent his army of penguins tall named Gunther} to attack the Candy Kingdom.1 The (Sandyr Kingdom's wise ruler. Princess...

i dont understand the question and how to do...........

The evil Ice King has sent his army of penguins tall named Gunther} to attack the Candy Kingdom.1 The(Sandyr Kingdom's wise ruler. Princess Bubblegum. has devised a defence to ward off the invading penguinarmy. Princess Bubbleg um’s 'Fish-a- pult' will lob barrels of fish onto the battlefield. This will cover an areaof the battlefield with fish within which the penguins will stop to feed. and then. too full to fig ht. will retreatfor an aftemoon nap. Suppose we have a 2D integer array representing the battlefield. Each array value represents the numberof penguins currently in a 1 square meter area of the battlefield. Thus. a 100 by 100 array would representa 100m by 100m battlefield. and each value in the array is the number of penguins in the correspondingone square meter. The Fish-a-pult can fire barrels of fish of different weights. The weight of the fish barrel determines the sizeof the square area-2 that will be covered by fish when the barrel explodes on impact. If a barrel weighs n.pounds. then it covers a square area 2n + 1 meters on each side. Thus. a l-pound barrel of fish will covera 3m square area {corresponding to a 3 by 3 slice of the arrayfl. Your Task Yourjob is to write a part of the targeting software for the Fish-a-pult.Write a function called finLtaIgat_1ocation which has the following parameters: a battlefield: a 2D integer array representing the current state of the battlefield {containing the num-ber of penguins at each location. as above} I flaLveig-ht: an integer representing the weight of the barrel of fish to be fired. The weight alsodetermines the size of the area covered by fish. as above. Your function should return the optimal target location {as described below} as a tuple. i.e. the pair ofarray oifsets corresponding to the location. If there is more than one location tied for the most number ofpenguins. it does not matter which one you return. Your task is to detem'rine the optimal target location for a given quantity of fish. The optimal location is thebatttefield target location which. if hit with a barrel weighing fialL'Ha ight. pounds. will distract the mostpenguins. In other words. if the fiflh_fl'aigh‘i: is n. pounds. then find the center of the 2n + 1 by 2n. + 1 squareon the battlefield containing the most penguins. This can be done fairly easily using loops and slicing. ‘r'ouwill also find the numpy. aunt} function usefuL ‘r‘ou need not consider locations where the fish would land outside of the battlefield - these cannot beoptimal locations. A target location where the entire detonation area lies within the battlefield grid willalways be as good as or better than a target location where the detonation area falls off the grid becausewe know there are zero penguins outside the grid. If fialLHaight equals or exceeds either half of the battlefield width {not rounded}. or half of the battlefieldheight {not rounded}. then this means that the detonation area is larger than the entire battlefield. Thus.there are no target locations where the detonation area falls entirely within the battlefield grid. In such acase. return Hone. Firing more fish than needed to cover the entire battlefield is a waste of tasty fish!
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question