Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from 1 to 100 for three categories: problem clarity, originality, and difficulty.
앨리스와 밥은 각각 해커랭크에 문제를 하나 만들었다. 한 리뷰어는 세 개의 카테코리(명확성, 독창성, 난이도)에 대해 1부터 100까지 점수를 매겨 채점한다.
The rating for Alice's challenge is the triplet a = (a[0], a[1], a[2]), and the rating for Bob's challenge is the triplet b = (b[0], b[1], b[2]).
앨리스의 챌린지의 점수는 a = (a[0], a[1], a[2])이고 밥의 챌린지 점수는 b = (b[0], b[1], b[2])이다.
The task is to find their comparison points by comparing a[0] with b[0], a[1] with b[1], and a[2] with b[2].
테스크는 a[0] with b[0], a[1] with b[1], and a[2] with b[2]를 비교하여 그들의 비교 포인트를 찾는 것이다.
If a[i] > b[i], then Alice is awarded 1 point. 이 경우 앨리스가 1점을 얻는다.
If a[i] < b[i], then Bob is awarded 1 point. 이 경우 밥이 1점을 얻는다.
If a[i] = b[i], then neither person receives a point. 같은 경우 둘 다 점수가 없다.
Comparison points is the total points a person earned.
비교된 점수는 그들이 얻은 총점이다.
Given a and b, determine their respective comparison points.
주어진 a와 b, 그들의 각각 비교 포인트를 결정해라.
a = [1, 2, 3]
b = [3, 2, 1]
Complete the function compareTriplets in the editor below.
compareTriplets has the following parameter(s):
int a[3]: Alice's challenge rating
int b[3]: Bob's challenge rating
int[2]: Alice's score is in the first position, and Bob's score is in the second.
The first line contains 3 space-separated integers, a[0], a[1], and a[2], the respective values in triplet a.
The second line contains 3 space-separated integers, b[0], b[1], and b[2], the respective values in triplet b.
1 ≤ a[i] ≤ 100
1 ≤ b[i] ≤ 100
5 6 7
3 6 10
1 1
In this example:
Now, let's compare each individual score:
, so Alice receives point.
, so nobody receives a point.
, so Bob receives point.
Alice's comparison score is , and Bob's comparison score is . Thus, we return the array .
17 28 30
99 16 8
2 1
Comparing the elements, so Bob receives a point.
Comparing the and elements, and so Alice receives two points.
The return array is .
...
// Complete the compareTriplets function below.
function compareTriplets(a, b) {
let scoreA = 0;
let scoreB = 0;
for(let i = 0; i < 3; i++){
if(a[i] > b[i]){
scoreA = scoreA +1;
}else if(a[i] < b[i]) {
scoreB = scoreB +1;
}
}
return [scoreA, scoreB];
}
...
문제에 번역도 써보려했는데,,,, 넘나 길어서 다음부턴 안쓸까한다....🙄