Amazon | Phone | Super-spread tracker
Anonymous User
722

"""Covid-19 tracking

We're doing COVID-19 tracking prototype.

We have several persons located in two-dimensional map.
Each person record has a unique PERSON, a set of (X, Y)
coordinates, and a DISTANCE_RADIUS. The DISTANCE_RADIUS represents the area
around the PERSON that will infect person if another PERSON in it's DISTANCE_RADIUS

Need to write a function which takes list of PERSON's and
determines which one of them may infect biggest number of people
The function should return person's name and the total number of posible
people infected

Note: will be helpuf to usdestsnd the question if you try to visualize the location of each persone by using (x,y) coordinates
"""



def most_persons(persons: Sequence[Person]) -> (str, int):
    """Finds the posible persons, that cause most infection.

    Returns the name of the person, that cause most infection, and the number of persons
    that infected.
    """
    #  Your code start here!




from dataclasses import dataclass
from math import sqrt
from typing import Sequence


@dataclass
class Person:
    name: str
    x: float
    y: float
    dictance_radius: float

    def distance(self, other: "Person") -> float:
        return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2)


   def most_persons(persons: Sequence[Person]) -> (str, int):
    """Finds the largest infection spread.

    Returns the name of the starting person, and the number of persons
    infeted.
    """
    #  Your code start here!


persons = [
    Person("C", 7, 13, 3),
    Person("O", 6.5, 17, 5),
    Person("V", 12, 10, 4.5),
    Person("I", 14.5, 7, 3.5),
    Person("D", 17, 9, 2),
    Person("1", 7, 11, 2.5),
    Person("9", 8.5, 11.5, 3),
]

print(most_persons(persons) == ("V", 6))
Comments (1)