HackerRank Compare the Triplets Problem Solution C Solution
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>
int main(){
int a0;
int a1;
int a2;
scanf("%d %d %d",&a0,&a1,&a2);
int b0;
int b1;
int b2;
scanf("%d %d %d",&b0,&b1,&b2);
int sc1=0;
int sc2=0;
if(a0>b0){sc1=sc1+1;}
else if(a0<b0){sc2=sc2+1;}
if(a1>b1){sc1=sc1+1;}
else if(a1<b1){sc2=sc2+1;}
if(a2>b2){sc1=sc1+1;}
else if(a2<b2){sc2=sc2+1;}
printf("%d %d",sc1,sc2);
return 0;
}
HackerRank Compare the Triplets Problem Solution Javascript Solution
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");
main();
});
function readLine() {
return input_stdin_array[input_currentline++];
}
/////////////// ignore above this line ////////////////////
function main() {
var a0_temp = readLine().split(' ');
var a0 = parseInt(a0_temp[0]);
var a1 = parseInt(a0_temp[1]);
var a2 = parseInt(a0_temp[2]);
var b0_temp = readLine().split(' ');
var b0 = parseInt(b0_temp[0]);
var b1 = parseInt(b0_temp[1]);
var b2 = parseInt(b0_temp[2]);
var aTot = 0;
var bTot = 0;
a0 - b0>0?++aTot:a0-b0<0?++bTot:void(0);
a1 - b1>0?++aTot:a1-b1<0?++bTot:void(0);
a2 - b2>0?++aTot:a2-b2<0?++bTot:void(0);
console.log(aTot, bTot);
}
0 Comments