Skip to content
Programming101
Programming101

Learn everything about programming

  • Home
  • CS Subjects
    • IoT – Internet of Things
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programming101

Learn everything about programming

Codechef Tasty Decisions problem solution

YASH PAL, 31 July 2024

In this Codechef Tasty Decisions problem 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 XX.

Each piece of candy has a tastiness of YY.

One packet of chocolate contains 22 bars, while one packet of candy contains 55 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.

Codechef Tasty Decisions problem solution

Problem solution in Python programming.

# cook your dish here
n=int(input())
for i in range(n):
    x,y=map(int,input().split())
    a=2*x 
    b=5*y
    if(a>b):
        print("Chocolate")
    elif(a==b):
        print("Either")
    else:
        print("Candy")

Problem solution in Java programming.

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
	{
		Scanner sc=new Scanner(System.in);
		int T=sc.nextInt();
		for(int i=0;i<T;i++){
		    int X=sc.nextInt();
		    int Y=sc.nextInt();
		    int z=X*2;
		    int k=Y*5;
		    if(z>k){
		        System.out.println("chocolate");
		    }
		    else if(z==k){
		        System.out.println("either");
		    }
		    else{
                System.out.println("candy");
		}
		}	
	}
}

Problem solution in C++ programming.

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t=1;
	cin>>t;
	while(t--){
	    int x,y;
	    cin>>x>>y;
	    int tx=2*x,ty=5*y;
	    if(tx>ty)
	    cout<<"Chocolaten";
	    else if(ty>tx)
	    cout<<"Candyn";
	    else cout<<"Eithern";
	}
	return 0;
}

Problem solution in C programming.

#include <stdio.h>

int main(void) {
	// your code goes here
	int t,n,m;
	int x,y;
	scanf("%d",&t);
	for(int i=1;i<=t;i++){
	    scanf("%d %d",&x,&y);
	    n= 2*x;
	    m=5*y;
	    if(n>m){
	      printf("Chocolate");
	    }
	    else if(n<m){
	      printf("Candy");
	    }
	    else if(n==m){
	      printf("Either");
	    }
	   printf("n");
	}
	return 0;
}
Codechef Solutions coding problems solutions

Post navigation

Previous post
Next post
  • HackerRank Separate the Numbers solution
  • How AI Is Revolutionizing Personalized Learning in Schools
  • GTA 5 is the Game of the Year for 2024 and 2025
  • Hackerrank Day 5 loops 30 days of code solution
  • Hackerrank Day 6 Lets Review 30 days of code solution
How to download udemy paid courses for free

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
©2025 Programming101 | WordPress Theme by SuperbThemes