Python : Consider you are needed to buy the maximum number of PC within the allocated budget.
Question:
Python : Consider you are needed to buy the maximum number of PC within the allocated budget. For that, create function to find the maximum number of PC can buy within the budget. First line of the input has integers N (total no of PC for sale) and B (total budget). The second line has the N integers represents the cost of the each PC for sale, then the function should return the maximum number os PC can buy.
Sample Input
5 120
30 20 40 30 35
Sample Output
4
Explanation
There are 5 PC for sale with the prices 30, 20, 40, 30 and 35 and the budget is 120, out of this 4 PCs can buy.
Complete the code below.
# Enter your code here. Read input from STDIN. Print output to STDOUT
def buypc():
#Write your code here
return
if __name__ == "__main__":
print(buypc())
Introduction to Data Mining
ISBN: 978-0321321367
1st edition
Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar