Advertisement
Guest User

Untitled

a guest
Jan 20th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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.
  2.  
  3. We define the rating for Alice's challenge to be the triplet , and the rating for Bob's challenge to be the triplet .
  4.  
  5. Your task is to find their comparison points by comparing with , with , and with .
  6.  
  7. If , then Alice is awarded point.
  8. If , then Bob is awarded point.
  9. If , then neither person receives a point.
  10. Comparison points is the total points a person earned.
  11.  
  12. Given and , can you compare the two challenges and print their respective comparison points?
  13.  
  14. Input Format
  15.  
  16. The first line contains space-separated integers, , , and , describing the respective values in triplet .
  17. The second line contains space-separated integers, , , and , describing the respective values in triplet .
  18.  
  19. Constraints
  20.  
  21. Output Format
  22.  
  23. Print two space-separated integers denoting the respective comparison points earned by Alice and Bob.
  24.  
  25. Sample Input
  26.  
  27. 5 6 7
  28. 3 6 10
  29. Sample Output
  30.  
  31. 1 1
  32. Explanation
  33.  
  34. In this example:
  35.  
  36. Now, let's compare each individual score:
  37.  
  38. , so Alice receives point.
  39. , so nobody receives a point.
  40. , so Bob receives point.
  41. 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.
  42.  
  43. initial 'given':
  44.  
  45. using System;
  46. using System.Collections.Generic;
  47. using System.IO;
  48. using System.Linq;
  49. class Solution
  50. {
  51.  
  52. static int[] Solve(int a0, int a1, int a2, int b0, int b1, int b2)
  53. {
  54.  
  55. }
  56.  
  57.  
  58. static void Main(String[] args)
  59. {
  60. string[] tokens_a0 = Console.ReadLine().Split(' ');
  61. int a0 = Convert.ToInt32(tokens_a0[0]);
  62. int a1 = Convert.ToInt32(tokens_a0[1]);
  63. int a2 = Convert.ToInt32(tokens_a0[2]);
  64. string[] tokens_b0 = Console.ReadLine().Split(' ');
  65. int b0 = Convert.ToInt32(tokens_b0[0]);
  66. int b1 = Convert.ToInt32(tokens_b0[1]);
  67. int b2 = Convert.ToInt32(tokens_b0[2]);
  68. int[] result = Solve(a0, a1, a2, b0, b1, b2);
  69. Console.WriteLine(String.Join(" ", result));
  70.  
  71.  
  72. }
  73. }
  74.  
  75. what i have so far:
  76. int[] a_triplet = new int[3];
  77. int[] b_triplet = new int[3];
  78. for (int i = 0; i < 3; i++)
  79. {
  80. a_triplet[i] += 1;
  81. }
  82. for (int i = 0; i < 3; i++)
  83. {
  84. b_triplet[i] += 1;
  85. }
  86. int alice_points = 0;
  87. int bob_points = 0;
  88. for (int i = 0; i < 3; i++)
  89. {
  90. if (a_triplet[i] > b_triplet[i])
  91. {
  92. alice_points += 1;
  93. }
  94. else if (a_triplet[i] < b_triplet[i])
  95. {
  96. bob_points += 1;
  97. }
  98. }
  99.  
  100. int[] total = a_triplet.ToArray();
  101. total = b_triplet.ToArray();
  102. return total;
  103.  
  104. the 'editorial submissions' all seem to assume that 'Solve' is an int, though, not an array, it seems?
  105.  
  106. C
  107. #include<stdio.h>
  108.  
  109. int a_triplet[3], b_triplet[3];
  110. int alice_points = 0;
  111. int bob_points = 0;
  112.  
  113. int main() {
  114. for (int i = 0; i < 3; i++) {
  115. scanf("%d", &a_triplet[i]);
  116. }
  117. for (int i = 0; i < 3; i++) {
  118. scanf("%d", &b_triplet[i]);
  119. }
  120. for(int i = 0; i < 3; i++) {
  121. if (a_triplet[i] > b_triplet[i]) alice_points++;
  122. if (a_triplet[i] < b_triplet[i]) bob_points++;
  123. }
  124. printf("%d %d\n", alice_points, bob_points);
  125. return 0;
  126. }
  127. C++
  128. #include <bits/stdc++.h>
  129. using namespace std;
  130.  
  131. int main(){
  132. vector <int> a_triplet(3);
  133. vector <int> b_triplet(3);
  134. int alice_points = 0;
  135. int bob_points = 0;
  136.  
  137. for (int i = 0; i < 3; i++) {
  138. cin >> a_triplet[i];
  139. }
  140. for (int i = 0; i < 3; i++) {
  141. cin >> b_triplet[i];
  142. }
  143.  
  144. for(int i = 0; i < 3; i++) {
  145. if (a_triplet[i] > b_triplet[i]) alice_points++;
  146. if (a_triplet[i] < b_triplet[i]) bob_points++;
  147. }
  148. cout << alice_points << " " << bob_points << endl;
  149. return 0;
  150. }
  151. Python 2
  152. a_triplet = map(int, raw_input().split())
  153. b_triplet = map(int, raw_input().split())
  154. alice_points = 0
  155. bob_points = 0
  156. for a_val, b_val in zip(a_triplet, b_triplet):
  157. if a_val < b_val:
  158. bob_points += 1
  159. elif a_val > b_val:
  160. alice_points += 1
  161. print alice_points, bob_points
  162. Python 3
  163. a_triplet = map(int, input().split())
  164. b_triplet = map(int, input().split())
  165. alice_points = 0
  166. bob_points = 0
  167. for a_val, b_val in zip(a_triplet, b_triplet):
  168. if a_val < b_val:
  169. bob_points += 1
  170. elif a_val > b_val:
  171. alice_points += 1
  172. print(alice_points, bob_points)
  173. Ruby
  174. a_triplet = gets.strip.split(' ').map(&:to_i)
  175. b_triplet = gets.strip.split(' ').map(&:to_i)
  176.  
  177. alice_points = 0
  178. bob_points = 0
  179.  
  180. a_triplet.zip(b_triplet).each do |a_val, b_val|
  181. if a_val > b_val
  182. alice_points += 1
  183. elsif a_val < b_val
  184. bob_points += 1
  185. end
  186. end
  187.  
  188. puts "#{alice_points} #{bob_points}"
  189. Java
  190. import java.io.*;
  191. import java.util.*;
  192. import java.text.*;
  193. import java.math.*;
  194. import java.util.regex.*;
  195.  
  196. public class Solution {
  197. public static void main(String[] args) {
  198. Scanner in = new Scanner(System.in);
  199. int[] a_triplet = new int[3];
  200. int[] b_triplet = new int[3];
  201. for (int i = 0; i < 3; i++) {
  202. a_triplet[i] = in.nextInt();
  203. }
  204. for (int i = 0; i < 3; i++) {
  205. b_triplet[i] = in.nextInt();
  206. }
  207. int alice_points = 0;
  208. int bob_points = 0;
  209. for (int i = 0; i < 3; i++) {
  210. if (a_triplet[i] > b_triplet[i]) {
  211. alice_points += 1;
  212. } else if (a_triplet[i] < b_triplet[i]) {
  213. bob_points += 1;
  214. }
  215. }
  216. System.out.printf("%d %d", alice_points, bob_points);
  217. }
  218. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement