Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Alice and Bob each created one problem for HackerRank. A reviewer rates the two challenges, awarding points on a scale from to for three categories: problem clarity, originality, and difficulty.
- We define the rating for Alice's challenge to be the triplet , and the rating for Bob's challenge to be the triplet .
- Your task is to find their comparison points by comparing with , with , and with .
- If , then Alice is awarded point.
- If , then Bob is awarded point.
- If , then neither person receives a point.
- Comparison points is the total points a person earned.
- Given and , can you compare the two challenges and print their respective comparison points?
- Input Format
- The first line contains space-separated integers, , , and , describing the respective values in triplet .
- The second line contains space-separated integers, , , and , describing the respective values in triplet .
- Constraints
- Output Format
- Print two space-separated integers denoting the respective comparison points earned by Alice and Bob.
- Sample Input
- 5 6 7
- 3 6 10
- Sample Output
- 1 1
- Explanation
- 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 print 1 1 (Alice's comparison score followed by Bob's comparison score) on a single line.
- initial 'given':
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- class Solution
- {
- static int[] Solve(int a0, int a1, int a2, int b0, int b1, int b2)
- {
- }
- static void Main(String[] args)
- {
- string[] tokens_a0 = Console.ReadLine().Split(' ');
- int a0 = Convert.ToInt32(tokens_a0[0]);
- int a1 = Convert.ToInt32(tokens_a0[1]);
- int a2 = Convert.ToInt32(tokens_a0[2]);
- string[] tokens_b0 = Console.ReadLine().Split(' ');
- int b0 = Convert.ToInt32(tokens_b0[0]);
- int b1 = Convert.ToInt32(tokens_b0[1]);
- int b2 = Convert.ToInt32(tokens_b0[2]);
- int[] result = Solve(a0, a1, a2, b0, b1, b2);
- Console.WriteLine(String.Join(" ", result));
- }
- }
- what i have so far:
- int[] a_triplet = new int[3];
- int[] b_triplet = new int[3];
- for (int i = 0; i < 3; i++)
- {
- a_triplet[i] += 1;
- }
- for (int i = 0; i < 3; i++)
- {
- b_triplet[i] += 1;
- }
- int alice_points = 0;
- int bob_points = 0;
- for (int i = 0; i < 3; i++)
- {
- if (a_triplet[i] > b_triplet[i])
- {
- alice_points += 1;
- }
- else if (a_triplet[i] < b_triplet[i])
- {
- bob_points += 1;
- }
- }
- int[] total = a_triplet.ToArray();
- total = b_triplet.ToArray();
- return total;
- the 'editorial submissions' all seem to assume that 'Solve' is an int, though, not an array, it seems?
- C
- #include<stdio.h>
- int a_triplet[3], b_triplet[3];
- int alice_points = 0;
- int bob_points = 0;
- int main() {
- for (int i = 0; i < 3; i++) {
- scanf("%d", &a_triplet[i]);
- }
- for (int i = 0; i < 3; i++) {
- scanf("%d", &b_triplet[i]);
- }
- for(int i = 0; i < 3; i++) {
- if (a_triplet[i] > b_triplet[i]) alice_points++;
- if (a_triplet[i] < b_triplet[i]) bob_points++;
- }
- printf("%d %d\n", alice_points, bob_points);
- return 0;
- }
- C++
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- vector <int> a_triplet(3);
- vector <int> b_triplet(3);
- int alice_points = 0;
- int bob_points = 0;
- for (int i = 0; i < 3; i++) {
- cin >> a_triplet[i];
- }
- for (int i = 0; i < 3; i++) {
- cin >> b_triplet[i];
- }
- for(int i = 0; i < 3; i++) {
- if (a_triplet[i] > b_triplet[i]) alice_points++;
- if (a_triplet[i] < b_triplet[i]) bob_points++;
- }
- cout << alice_points << " " << bob_points << endl;
- return 0;
- }
- Python 2
- a_triplet = map(int, raw_input().split())
- b_triplet = map(int, raw_input().split())
- alice_points = 0
- bob_points = 0
- for a_val, b_val in zip(a_triplet, b_triplet):
- if a_val < b_val:
- bob_points += 1
- elif a_val > b_val:
- alice_points += 1
- print alice_points, bob_points
- Python 3
- a_triplet = map(int, input().split())
- b_triplet = map(int, input().split())
- alice_points = 0
- bob_points = 0
- for a_val, b_val in zip(a_triplet, b_triplet):
- if a_val < b_val:
- bob_points += 1
- elif a_val > b_val:
- alice_points += 1
- print(alice_points, bob_points)
- Ruby
- a_triplet = gets.strip.split(' ').map(&:to_i)
- b_triplet = gets.strip.split(' ').map(&:to_i)
- alice_points = 0
- bob_points = 0
- a_triplet.zip(b_triplet).each do |a_val, b_val|
- if a_val > b_val
- alice_points += 1
- elsif a_val < b_val
- bob_points += 1
- end
- end
- puts "#{alice_points} #{bob_points}"
- Java
- import java.io.*;
- import java.util.*;
- import java.text.*;
- import java.math.*;
- import java.util.regex.*;
- public class Solution {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int[] a_triplet = new int[3];
- int[] b_triplet = new int[3];
- for (int i = 0; i < 3; i++) {
- a_triplet[i] = in.nextInt();
- }
- for (int i = 0; i < 3; i++) {
- b_triplet[i] = in.nextInt();
- }
- int alice_points = 0;
- int bob_points = 0;
- for (int i = 0; i < 3; i++) {
- if (a_triplet[i] > b_triplet[i]) {
- alice_points += 1;
- } else if (a_triplet[i] < b_triplet[i]) {
- bob_points += 1;
- }
- }
- System.out.printf("%d %d", alice_points, bob_points);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement