You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromtypingimportTuple# The while loop represents the game.# Each iteration represents a turn of the game# where you are given inputs (the heights of the mountains)# and where you have to print an output (the index of the mountain to fire on)# The inputs you are given are automatically updated according to your last actions.# game loopwhileTrue:
biggest: Tuple[int, int] = (-1, -1)
foriinrange(8):
mountain_h=int(input()) # represents the height of one mountain.biggest= (i, mountain_h) ifbiggest[1] <mountain_helsebiggest# The index of the mountain to fire on.print(biggest[0])
TypeScript
/** * The while loop represents the game. * Each iteration represents a turn of the game * where you are given inputs (the heights of the mountains) * and where you have to print an output (the index of the mountain to fire on) * The inputs you are given are automatically updated according to your last actions. **/// game loopwhile(true){letbiggest: {index: number;height: number};for(leti=0;i<8;i++){constmountainH: number=parseInt(readline());// represents the height of one mountain.(!biggest||biggest.height<mountainH)&&(biggest={index: i,height: mountainH});}console.log(biggest.index);// The index of the mountain to fire on.}
Java
importjava.util.*;
/** * The while loop represents the game. * Each iteration represents a turn of the game * where you are given inputs (the heights of the mountains) * and where you have to print an output (the index of the mountain to fire on) * The inputs you are given are automatically updated according to your last actions. **/classPlayer {
publicstaticvoidmain(Stringargs[]) {
Scannerin = newScanner(System.in);
// game loopwhile (true) {
Mountainbiggest = null;
for (inti = 0; i < 8; i++) {
intmountainH = in.nextInt(); // represents the height of one mountain.if (biggest == null || biggest.height < mountainH) biggest = newMountain(i, mountainH);
}
System.out.println(biggest.index); // The index of the mountain to fire on.
}
}
}
classMountain {
publicintindex;
publicintheight;
publicMountain(intindex, intheight) {
this.index = index;
this.height = height;
}
}
constn: number=parseInt(readline());// the number of temperatures to analysevarinputs: string[]=readline().split(' ');constarray: number[]=[];for(leti=0;i<n;i++){constt: number=parseInt(inputs[i]);// a temperature expressed as an integer ranging from -273 to 5526array.push(t);}letclosest: {temperature: number;gap: number|null}={temperature: 0,gap: null};for(leti=0;i<array.length;i++){constgap=Math.abs(array[i]-0);constdata={temperature: array[i],
gap
}if(!closest.gap||closest.gap>data.gap||(closest.gap===data.gap&&data.temperature>closest.temperature))closest=data;}console.log(closest.temperature);
constN: number=parseInt(readline());// Number of elements which make up the association table.constQ: number=parseInt(readline());// Number Q of file names to be analyzed.constmap=newMap();for(leti=0;i<N;i++){varinputs: string[]=readline().split(" ");constEXT: string=inputs[0];// file extensionconstMT: string=inputs[1];// MIME type.map.set(EXT.toLowerCase(),MT);}for(leti=0;i<Q;i++){constFNAME: string=readline();// One file name per line.consttemp=FNAME.split(".");if(temp.length<=1){console.log("UNKNOWN");continue;}constextension=temp[temp.length-1].toLowerCase();console.error(FNAME,extension);map.get(extension) ? console.log(map.get(extension)) : console.log("UNKNOWN");}