Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You have some water and some buckets to fill. Write a program called water_011.py that reads two lines of text from stdin. Line 1 contains

  • You have some water and some buckets to fill.

  • Write a program called water_011.py that reads two lines of text from stdin.

  • Line 1 contains a single integer, N, the number of litres of water available. N is in the range 0-1000.

  • Line 2 lists the capacity in litres of one or more buckets. The capacity of each bucket is specified by a positive integer.

  • Buckets must be filled in the order specified on line 2.

  • Your program should output the number of buckets that can be completely filled before you run out of water.

  • In this example we have 10 litres of water. We fill the first bucket (taking 6 litres), we fill the second bucket (taking another 2 litres) but we run out of water before we have completely filled the third bucket (it requires 5 litres). We output 2 (the number of buckets completely filled):

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions