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
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())
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 StartedRecommended Textbook for
Introduction to Data Mining
Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar
1st edition
321321367, 978-0321321367
Students also viewed these Algorithms questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App