PROBLEM 6 (12 pts) - Automatic selling in auction Write a function which receives as input a list of numbers, representi
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
PROBLEM 6 (12 pts) - Automatic selling in auction Write a function which receives as input a list of numbers, representi
PROBLEM 6 (12 pts) - Automatic selling in auction Write a function which receives as input a list of numbers, representing the bids placed by candidate buyers and the limitPrice which determines the lowest price at which the item can be sold. The function should return as result a tuple of three values representing the index of the winning bid, the offered amount of the winning bid and the final price of the selling. def sellInAuction(listOfBids, limitPrice): The final price is determined according to these regulations: - If there are more than one bids higher than the limitPrice and the highest bidder is unique, then the highest bidder wins and the final selling price will be ( 1 + secondHighest Bid) - If there are more than one bids higher than the limitPrice then the highest bidder is not unique, then the highest bidder with the smallest index wins and the final selling price will be the highest bid. - If there is only one bid higher than the limitPrice, then this bidder wins and the final selling price is equal to the limitPrice. - If none of the bids is higher than the limitPrice, then the function will return the value None Some examples: sellInAuction ([5,12,4,3,5,8,7], 4) --> (1, 12, 9) sellInAuction ([5,8,4,12,9,8,12,6], 10) --> (3, 12, 12) sellInAuction ([5,12,4,3,5,8,7], 10) --> (1, 12, 10) sellInAuction ([5,12,4,3,5,8,7], 15) --> None
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!