Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Tasty Decisions CodeChef Solution

Problem – Tasty Decisions CodeChef Solution

Chef is buying sweet things to prepare for Halloween!

The shop sells both chocolate and candy.

  • Each bar of chocolate has a tastiness of X.
  • Each piece of candy has a tastiness of Y.

One packet of chocolate contains 2 bars, while one packet of candy contains 5 pieces.

Chef can only buy one packet of something sweet, and so has to make a decision: which one should he buy in order to maximize the total tastiness of his purchase?

Print Chocolate if the packet of chocolate is tastier, Candy if the packet of candy is tastier, and Either if they have the same tastiness.

Input Format

  • The first line of input will contain a single integer T, denoting the number of test cases.
  • Each test case consists of one line of input, containing two space-separated integers X and Y — the tastiness of one bar of chocolate and one piece of candy, respectively.

Output Format

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

  • Chocolate if the packet of chocolate is tastier.
  • Candy if the packet of candy is tastier.
  • Either if they have the same tastiness.

You may print each character of the output in either uppercase or lowercase, i.e, CandyCANDYCaNdY and cANDy will all be treated as equivalent.

Constraints

  • 1≤T≤100
  • 1≤X,Y≤10

Sample 1:

Input: 
4
5 1
5 2
5 3
3 10
Output: 
Chocolate
Either
Candy
Candy

Explanation:

Test case 1: The packet of chocolate has a tastiness of  2×5=10, while the packet of candy has a tastiness of 5×1=5. The chocolate is tastier.

Test case 2: The packet of chocolate has a tastiness of 2×5=10, while the packet of candy has a tastiness of  5×2=10. They have the same tastiness.

Test case 3: The packet of chocolate has a tastiness of 2×5=10, while the packet of candy has a tastiness of 5×3=15. The candy is tastier.

Test case 4: The packet of chocolate has a tastiness of 2×3=6, while the packet of candy has a tastiness of 5×10=50. The candy is tastier.

Tasty Decisions CodeChef Solution in Python3

for i in range(int(input())):
    a, b = map(int, input().split())
    if a*2 == b*5 :
        print("either")
    elif a*2  < b*5:
        print("candy")
    else:
        print("chocolate")

Tasty Decisions CodeChef Solution in C++17

#include <bits/stdc++.h>
using namespace std;

int main() {
	   int t;
	   cin>>t;
	   while(t--){
	       int x,y;
	       cin>>x>>y;
	       if((x*2)>(y*5)){
	           cout<<"chocolate\n";
	       }
	       else if((y*5)>(x*2)){
	           cout<<"candy\n";
	       }
	       else cout<<"either\n";
	   }
	return 0;
}

Tasty Decisions CodeChef Solution in Java

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

import java.util.*;
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 sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		while (n-- > 0) {
		    int chocolate = sc.nextInt();
		    int candy = sc.nextInt();
		    if (2*chocolate > 5*candy) {
		        System.out.println("Chocolate");
		    } else if (2*chocolate < 5*candy) {
		        System.out.println("Candy");
		    } else {
		        System.out.println("Either");
		    }
		}
	}
}
Tasty Decisions CodeChef Solution Review:

In our experience, we suggest you solve this Tasty Decisions 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 Tasty Decisions CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Tasty Decisions 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

Leave a Reply

Your email address will not be published. Required fields are marked *