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
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