Created
May 30, 2017 19:08
-
-
Save Woodsphreaker/600691941b6e7c4d99ffa79e517e6ce4 to your computer and use it in GitHub Desktop.
Hacker Rank - Desafio Compare the Triplets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 solve(a0, a1, a2, b0, b1, b2) { | |
const player1 = [a0, a1, a2] | |
const player2 = [b0, b1, b2] | |
return player1.reduce((acc, cur, i) => { | |
[].concat(cur > player2[i] ? acc[0]++ : player2[i] > cur ? acc[1]++ : 0) | |
return acc | |
}, [0, 0]) | |
} | |
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 result = solve(a0, a1, a2, b0, b1, b2); | |
console.log(result.join(" ")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment