Skip to content

Instantly share code, notes, and snippets.

@Asatelit
Last active January 19, 2021 23:38
Show Gist options
  • Save Asatelit/864919b7f0f6c18e4b21ed029ec64d27 to your computer and use it in GitHub Desktop.
Save Asatelit/864919b7f0f6c18e4b21ed029ec64d27 to your computer and use it in GitHub Desktop.
/*
Solution for HackerRank > Algorithms > Warmup > Compare the Triplets
https://www.hackerrank.com/challenges/compare-the-triplets
*/
(function solve(a0, a1, a2, b0, b1, b2) {
var aa = [a0, a1, a2];
var bb = [b0, b1, b2];
var a = 0;
var b = 0;
aa.forEach((element, index) => {
var ax = aa[index];
var bx = bb[index];
if (ax === bx) return; // neither person receives a point
return ax > bx ? a += 1 : b += 1;
});
return [a, b];
})(5, 6, 7, 3, 6, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment