Question: Compare the Triplets in C++: https://www.hackerrank.com/challenges/compare-the-triplets/problem Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a
Compare the Triplets in C++: https://www.hackerrank.com/challenges/compare-the-triplets/problem
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.
We define the rating for Alice's challenge to be the triplet A= (a[0],a[1],a[2]), and the rating for Bob's challenge to be the triplet B= (b[0],b[1],b[2])..
Your task is to find their comparison points by comparing a0 with b0, a1 with b1, and a2 with b2.
If a[i]>b[i], then Alice is awarded point.
If a[i]
If a[i]=b[i], then neither person receives a point.
Comparison points are the total points a person earned.
Given A and B, can you compare the two challenges and print their respective comparison points?
Input Format
The first line contains 3 space-separated integers, a0, a1, and a2, describing the respective values in triplet A. The second line contains space-separated integers, b0, b1, and b2, describing the respective values in triplet B.
Constraints
1<= ai <= 100
1<= bi<= 100
Output Format
Print two space-separated integers denoting the respective comparison scores earned by Alice and Bob.
Sample Input
5 6 7 3 6 10
Sample Output
1 1
Explanation
In this example:
A = (5,6,7)
B = (3,6,10)
Now, let's compare each individual score:
a[0]>b[0], so Alice receives 1 point.
a[1] = b[1], so nobody receives a point.
a[2] < b[2] so Bob receives 1 point.
Alice's comparison score is , and Bob's comparison score is . Thus, we print 1 1 (Alice's comparison score followed by Bob's comparison score) on a single line.
#include
using namespace std;
vector
/* * Complete the solve function below. */ vector
}
int main() { ofstream fout(getenv("OUTPUT_PATH"));
string a0A1A2_temp; getline(cin, a0A1A2_temp);
vector
int a0 = stoi(a0A1A2[0]);
int a1 = stoi(a0A1A2[1]);
int a2 = stoi(a0A1A2[2]);
string b0B1B2_temp; getline(cin, b0B1B2_temp);
vector
int b0 = stoi(b0B1B2[0]);
int b1 = stoi(b0B1B2[1]);
int b2 = stoi(b0B1B2[2]);
vector
for (int result_itr = 0; result_itr < result.size(); result_itr++) { fout << result[result_itr];
if (result_itr != result.size() - 1) { fout << " "; } }
fout << " ";
fout.close();
return 0; }
vector
input_string.erase(new_end, input_string.end());
while (input_string[input_string.length() - 1] == ' ') { input_string.pop_back(); }
vector
size_t i = 0; size_t pos = input_string.find(delimiter);
while (pos != string::npos) { splits.push_back(input_string.substr(i, pos - i));
i = pos + 1; pos = input_string.find(delimiter, i); }
splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1));
return splits; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
