Question: Please answer in PYTHON 3, thank you Hurricane Simulation Max is studying the movement of suspended particles inside a hurricane by using a simulator to
Please answer in PYTHON 3, thank you





Hurricane Simulation Max is studying the movement of suspended particles inside a hurricane by using a simulator to predict their movements. The simulation does not track the height of the particles though, just the (x,y) coordinates of the particle on the ground. The entire simulation takes place in 2-dimensions. There are n particles, and each one is given a starting position: p1,,pn in the simulator. The simulator has a simple model for movement of each particle: it is assumed that all the particles will move in a spiral like manner, although each will have its own parameters. Specifically, for each particle, Max associates an update vector (vx,vy) which will always be used to update the position of that particle throughout the entire simulation. (Each particle has its own update vector.) The rule to obtain the new position of a particle, (x,y), from its current position (x,y) using update vector (vx,vy) is given by the matrix computation: (xy)=(vxvyvyvx)(xy) or more directly: x=vxxvyy and y=vyx+vxy In order to represent a diverse set of possible spirals, vx and vy are not necessarily integers, but in order to preserve precision, they will each be presented as rational numbers. To represent the update vector (vx,vy), 4 integers: an,ad,bn,bd will be supplied, and should be interpreted that (vx,vy)=(an/ad,bn/bd) In a single "step" of the simulation, all the particles are updated by their update vector to compute their new positions. Those new positions are then used as the "current" positions for the next step, which again occurs with each particle's respective update vector. After performing t steps, Max wants to know how many particles lie within the rectangle with its lower left corner at (lx,ly) and its upper right corner at (ux,uy). Particles that lie on the boundary of the rectangle should be included in the count. Help Max by writing a program to efficiently perform the steps of his simulation. Input Format Line 1: lx ly ux uy: 4 space separated integers representing the coordinates of the rectangle's bounding box Line 2: tn:2 space separated integers representing the number of simulation steps and the number of particles, respectively Each of the following n lines contains 6 space separated integers in the format x y an ad bn bd where x,y are the coordinates of the starting point of the particle and an/ad, bn/bd are the components of its update vector Constraints 1t100001n10000105lxux105105lyuy105105x,y105105an,bn105105ad,bd105 Output Format Output a single integer indicating the number of particles within the rectangle defined by the bounding box, after t steps of the simulation have been completed. Sample Input 0 122541012125121212382313471434 Sample Output 0 2 Explanation 0 From the input, we see that we are interested in points that end up in the rectangle (parallel to the axes) with (0,1) at its lower left and (2,2) at its upper right. There are 4 particles in total, and their starting positions as well as their update vectors are set out in the table below. Also indicated is the position of the point after each of the 5 steps. To explain further, let us describe how we obtained the position of particle 2 after a single step: Particle 2 is evolved with the updated vector (21,21) and is initially located at the point (5,12). According to the update rule, after 1 step, it will be located at (21(5)21(12),21(5)+21(12))=(2512,2512)=(27,217) All the other steps were performed in the same way (using the appropriate vectors and points, of course). Examining the coordinates of the particles after the 5th step, we see that Particle 1 and Particle 3 are the only ones within the bounding rectangle of interest, so we return 2 as our
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
