Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Good day I will like some help with this code and please write it in python 3 Max is studying the movement of suspended particles
Good day I will like some help with this code and please write it in python 3
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. 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 u 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)=(vzvyvyvx)(xy) or more directly: x=vxxvyyy=vyx+vxy In order to represent a diverse set of possible spirals, vx and vy are not necessarily integers, but in order to 4 integers: an,ad,bn,bd will be supplied, and should be interpreted that 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 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 forma 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 1t10000 105lxux105 105lyuy1 105x,y105 105an,bn105 105ad,bd105 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 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
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