304 North Cardinal St.
Dorchester Center, MA 02124

# Chef and Balls CodeChef Solution

## Chef and Balls CodeChef Solution in C++14

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

int main()
{
cout<<1<<endl;

cout<<3<<" "<<1<<" "<<1<<" "<<3<<endl;

cout<<3<<" "<<4<<" "<<4<<" "<<5<<endl;

int an;
cin>>an;
cout<<2<<endl;
if(an==2)
cout<<1;
else if(an==0)
cout<<2;
else if(an==1)
cout<<3;
else if(an==-2)
cout<<4;
else if(an==-1)
cout<<5;
cout<<endl;
return 0;
}``````

## Chef and Balls CodeChef Solution in PYTH 3

``````# cook your dish here
import sys
print(2)
print(color)

print(1)
print(3,1,2,2) #pan1
print(3,3,4,4) #pan2
sys.stdout.flush()
ans = int(input())
if ans == 1:
elif ans == 2:
elif ans == -1:
elif ans == -2:
elif  ans == 0:

## Chef and Balls CodeChef Solution in C

``````#include <stdio.h>

int main() {
int t;

setbuf(stdout, NULL);

printf("1\n");
printf("3 1 1 3\n");
printf("3 2 2 4\n");

scanf("%d",&t);

printf("2\n");
if(t == 2) {
printf("1\n");
}
if(t == 1) {
printf("3\n");
}
if(t == 0) {
printf("5\n");
}
if(t == -1) {
printf("4\n");
}
if(t == -2) {
printf("2\n");
}

return 0;
} ``````

## Chef and Balls CodeChef Solution in JAVA

``````import java.io.BufferedInputStream;
import java.io.IOException;

public class Main {
static BufferedInputStream buffInput;

public static void main(String[] args) {

buffInput = new BufferedInputStream(System.in);
int t;
int x;
int i=1;
System.out.println("1\n1 1\n1 2")      ;
System.out.flush();

if(x == -1){
System.out.println("2\n1");
}else if(x==1){
System.out.println("2\n2");
}else {
System.out.println("1\n1 3\n1 4");
System.out.flush();
if(x == -1){
System.out.println("2\n3");
}else if(x==1){
System.out.println("2\n4");
}else {
System.out.println("2\n5");
}
}
System.exit(0);

}

int no = 0;
boolean minus = false;
try {
while (a == 32 || a == 10) //10 is newline & 32 is ASCII for space
if (a == '-') {
minus = true;
}
while (a != 10 && a != 32 && a != -1) {
no = no * 10 + (a - '0');
}
} catch (IOException e) {
e.printStackTrace();
}
return minus ? -no : no;
}
}``````

## Chef and Balls CodeChef Solution in PYPY 3

``````# cook your dish here
import sys
print(2)
print(color)

print(1)
print(3,1,2,2) #pan1
print(3,3,4,4) #pan2
sys.stdout.flush()
ans = int(input())
if ans == 1:
elif ans == 2:
elif ans == -1:
elif ans == -2:
elif  ans == 0:

## Chef and Balls CodeChef Solution in PYTH

``````import sys
print '1'
print '3 5 5 4'
print '3 1 1 2'
sys.stdout.flush()
n = int(raw_input())
r = n+3
print '2'
print r
sys.exit()
``````

## Chef and Balls CodeChef Solution in C#

``````using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChefAndBalls
{
class Program
{
static void Main(string[] args)
{

//first Iteration
Console.WriteLine(1);

//On left scale
Console.WriteLine("3 4 4 1");
//On Right scale
Console.WriteLine("3 2 5 5");

if (scaleMeasure == 0)
{
Console.Clear();
Console.WriteLine(2);
Console.WriteLine(3); //3 is heaviest
}
else if (scaleMeasure == 1)
{
Console.Clear();

//use the scale again
Console.WriteLine(2);
Console.WriteLine(1);  //1 is heavier
}
else if (scaleMeasure == -1)
{
Console.Clear();

//use the scale again
Console.WriteLine(2);
Console.WriteLine(2);  //2 is heavier
}
else if (scaleMeasure == 2)
{
Console.Clear();

//use the scale again
Console.WriteLine(2);
Console.WriteLine(4);  //4 is heavier
}
else if (scaleMeasure == -2)
{
Console.Clear();

Console.WriteLine(2);
Console.WriteLine(5); //5 is heaviest
}
}

}
}``````

## Chef and Balls CodeChef Solution in NODEJS

``````/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};

/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {

/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId])
/******/ 			return installedModules[moduleId].exports;

/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			exports: {},
/******/ 			id: moduleId,
/******/ 		};

/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

/******/ 		// Flag the module as loaded

/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}

/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;

/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;

/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";

/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {

//Works for hackerrank and codechef - anything where
//node file.js <in.txt >out.txt would work
//
//

process.stdout = process.stderr;
console.log("1");
//process.stdout.flush();
console.log("3 1 1 2");
//process.stdout.flush();
console.log("3 3 3 4");
//process.stdout.flush();

var f = __webpack_require__(1).singleLine(main);
//var file = require('./algorithms/file.js').hackerrank(main);

function main(contentLines) {
var x = +contentLines;
console.log("2");
//process.stdout.flush();
if(x===0) console.log("5");
if(x===2) console.log("1");
if(x===1) console.log("2");
if(x===-1) console.log("4");
if(x===-2) console.log("3");
//process.stdout.flush();
/*for (var i = 1; i < contentLines.length; i++) {
var els = contentLines[i].split(" "),
activities = +els[0],
isIndian = els[1] === "INDIAN";

var score = 0;
while (activities) {
els = contentLines[++i].split(" ");

if(els[0]==="CONTEST_WON") score+= (+els[1] <=20) ? 300+20 - +els[1] : 300;
else if(els[0]==="TOP_CONTRIBUTOR") score+=300;
else if(els[0]==="BUG_FOUND") score+= +els[1];
else score+=50;
activities--;
}

var ans;
if(isIndian) ans = Math.floor(score/200);
else ans = Math.floor(score/400);
console.log(ans);
}*/
}

/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {

var f = {

hackerrank: function(callback) {
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function(data) {
input_stdin += data;
});

process.stdin.on('end', function() {
input_stdin_array = input_stdin.split("\n").filter(function(el) {
return el.length !== 0;
});
callback(input_stdin_array);
});
},

singleLine: function(callback) {
input: process.stdin,
output: process.stdout,
terminal: false
});

rl.on('line', function(cmd) {
callback(cmd);
});
}

};

module.exports = f;

/***/ },
/* 2 */
/***/ function(module, exports) {

/***/ }
/******/ ]);``````
##### Chef and Balls CodeChef Solution Review:

In our experience, we suggest you solve this Chef and Balls 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 Chef and Balls CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this Chef and Balls 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 Programming Language in a business context; there are no prerequisites.

Keep Learning!