Question: Python 3: Youre visiting your hometown and are planning to stay at a friends house. It just happens that all your friends live on the

Python 3: Youre visiting your hometown and are planning to stay at a friends house. It just happens that all your friends live on the same street. In order to be efficient, you would like to stay at the house of a friend who is in a central location in the following sense: the same number of friends, within 1, live in either direction. If two friends houses satisfy this criterion, choose the friend with the smaller street address.

Write function address() that takes a list of street numbers and returns the street number you should stay at.

>>> address([2, 1, 8, 5, 9])

5

>>> address([2, 1, 8, 5])

2 >>> address([1, 1, 1, 2, 3, 3, 4, 4, 4, 5])

3

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 Databases Questions!