Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

Students also viewed these Programming questions

Question

=+5." Redo your calculations.

Answered: 1 week ago