Which Mixture | CodeChef Solution

Hello coders, today we are going to solve Which Mixture CodeChef Solution whose Problem Code is MIXTURE.

Contents

Task

Chef has A units of solid and B units of liquid. He combines them to create a mixture. What kind of mixture does Chef produce: a solution, a solid, or a liquid?

A mixture is called a:

  1. A solution if A > 0 and B > 0,
  2. A solid if B = 0, or
  3. A liquid if A = 0.

Input Format

  • The first line contains T denoting the number of test cases. Then the test cases follow.
  • Each test case contains two space-separated integers A and B on a single line.

Output Format

For each test case, output on a single line the type of mixture Chef produces, whether it is a Solution, Solid, or Liquid. The output is case sensitive.

Constraints

  • 1 ≤ T ≤ 20
  • 0 ≤ A, B ≤ 100
  • A +B > 0

Subtasks

Subtask 1 (100 points): Original constraints

Sample Input 1

3
10 5
0 3
3 0

Sample Output 1

Solution
Liquid
Solid

Explanation

Test case 1: Chef adds both solid and liquid to the mixture, hence the mixture is a solution.
Test case 2: Chef does not add solid to the mixture, hence the mixture is liquid.
Test case 3: Chef does not add liquid to the mixture, hence the mixture is solid.

Solution – Which Mixture

C++

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int test;
	cin >> test;
	
	while (test--){
	    int a, b;
	    cin >> a >> b;
	    if (a == 0){
	        cout << "Liquid" << endl;
	    }
	    else if (b == 0){
	        cout << "Solid" << endl;
	    }
	    else{
	        cout << "Solution" << endl;
	    }
	}
	
	return 0;
}

Python

# cook your dish here
T = int(input())
while (T > 0):
    a, b = map(int, input().split())
    
    if (a == 0):
        print("Liquid")
    elif (b == 0):
        print("Solid")
    else:
        print("Solution")
        
    T = T - 1

Java

/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner input = new Scanner(System.in);
		int test = input.nextInt();
		while (test > 0){
		    int a = input.nextInt();
		    int b = input.nextInt();
		    
		    if (a == 0){
		        System.out.println("Liquid");
		    }
		    else if (b == 0){
		        System.out.println("Solid");
		    }
		    else{
		        System.out.println("Solution");
		    }
		    test = test - 1;
		}
	}
}

Disclaimer: The above Problem (Which Mixture) is generated by CodeChef but the Solution is Provided by CodingBroz. This tutorial is only for Educational and Learning Purpose.

Leave a Comment

Your email address will not be published.