304 North Cardinal St.
Dorchester Center, MA 02124

# Bucket and Water Flow CodeChef Solution

## Problem – Bucket and Water Flow CodeChef Solution

Alice has a bucket of water initially having W litres of water in it. The maximum capacity of the bucket is X liters.

Alice turned on the tap and the water starts flowing into the bucket at a rate of Y litres/hour. She left the tap running for exactly Z hours. Determine whether the bucket has been overflown, filled exactly, or is still left unfilled.

### Input Format

• The first line of input will contain a single integer T, denoting the number of test cases. The description of the test cases follows.
• Each test case consists of a single line of input containing four space-separated integers WXYZ.

### Output Format

For each test case, print the answer on a new line:

• If the bucket has overflown print `overflow`
• If it is exactly filled print `filled`
• If it is still unfilled, print `unfilled`

You may print each character of the string in uppercase or lowercase (for example, the strings `filled``FIlled``fiLLed`, and `FILLED` will all be treated as identical).

### Constraints

• 1≤T≤1000
• 1≤W,X,Y,Z≤1000

• Original constraints.

### Sample 1:

``````Input: 4
1 2 3 4
10 70 10 6
2 100 4 3
4 3 2 1
Output: overFlow
filled
Unfilled
overflow``````

### Explanation:

Test case 1: Initially the bucket had 1 litre of water, we then added 3 litres of water for 4 hours. Thus, the total bucket inflow was 1+3×4=13 litres. Since this is greater than the capacity of 2 litres, the bucket will `OVERFLOW`

Test case 2: Initially the bucket had 10 litres of water, we then added 10 litres of water for 6 hours. Thus, the total bucket inflow was 10+10×6=70 litres. Since this is equal to the capacity of 70 litres, the bucket will be `FILLED`

Test case 3: Initially the bucket had 2 litres of water, we then added 4 litres of water for 3 hours. Thus, the total bucket inflow was 2+4×3=14 litres. Since this is lesser than the capacity of 100 litres, the bucket will be `UNFILLED`.

Test case 4: Initially the bucket had 4 litres of water, we then added 2 litres of water for 1 hours. Thus, the total bucket inflow was 4+2×1=6 litres. Since this is more than the capacity of 3 litres, the bucket will `OVERFLOW`.

### Bucket and Water Flow CodeChef Solution in C++17

``````#include <iostream>
using namespace std;

int main() {
int t; cin>>t; while(t--)
{
int w,x,y,z;
cin>>w>>x>>y>>z;
cout<<(x-w==y*z ? "Filled" : (x-w>y*z ? "Unfilled" : "Overflow"))<<endl;
}
return 0;
}
``````

### Bucket and Water Flow CodeChef Solution in Pyth 3

``````T = int(input())
for i in range(T):
W,X,Y,Z=map(int,input().split())
if W+(Y*Z)==X:
print("filled")
elif W+(Y*Z)>=X:
print("overflow")
elif W+(Y*Z)<=X:
print("unfilled")``````

### Bucket and Water Flow CodeChef Solution in Java

``````import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++)
{
int initw=sc.nextInt();
int maxw=sc.nextInt();
int ratew=sc.nextInt();
int hourw=sc.nextInt();
int ans=initw+(ratew*hourw);
if(ans==maxw) System.out.println("Filled");
else if(ans>maxw) System.out.println("Overflow");
else System.out.println("Unfilled");
}
}
}
``````
##### Bucket and Water Flow CodeChef Solution Review:

In our experience, we suggest you solve this Bucket and Water Flow CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Bucket and Water Flow CodeChef Solution

Find on CodeChef

##### Conclusion:

I hope this Bucket and Water Flow CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions