Question: Write a functioncontact_event(visit_a,visit_b)to determine if two visits overlap in time and space, allowing for contact between two people to potentially occur. The parameters of this

Write a functioncontact_event(visit_a,visit_b)to determine if two visits overlap in time and space, allowing for contact between two people to potentially occur.

The parameters of this function are as follows:

  • visit_a
  • visit_b

each of which is a 7-tupleformatted as described above.

The function should returnTrueif a contact could have occurred between two distinct people, andFalseotherwise. If one visit began at the exact time that the other visit ended, you may assume that a potential contact could not occur (ie, the function should returnFalse). If either of the visits is not valid, the function should returnNone.

Assumptions:

  • You can assume that the input arguments are syntactically correct given the definitions and assumptions on the previous slides.

Here are some example calls to the function:

>>> print(contact_event(('Russel', 'Foodigm', 2, 9, 0, 10, 0), ('Natalya', 'Foodigm', 2, 9, 30, 9, 45)))

True

>>> print(contact_event(('Russel', 'Foodigm', 2, 9, 0, 10, 0), ('Natalya', 'Foodigm', 2, 10, 0, 10, 20)))

False

>>> print(contact_event(("Natalya", 'Foodigm', 2, 9, 30, 9, 45), ('Chihiro', 'Foodigm', 2, 8, 45, 9, 15))) # there is no time overlap

False

>>> print(contact_event(('Russel', 'Foodigm', 2, 9, 0, 10, 0), ('Aravinda', 'Afforage', 2, 9, 0, 10, 0))) # the two visit were to different locations

False

>>> print(contact_event(('Russel', 'Foodigm', 2, 9, 0, 10, 0), ('Russel', 'Foodigm', 2, 8, 30, 9, 0))) # the two visits are by the same person

False

>>> print(contact_event(('Russel', 'Foodigm', 2, 9, 0, 10, 0), ('Natalya', 'Afforage', 2, 15, 10, 14, 45))) # one of the visits is invalid

None

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!