Skip to content

Commit e6a176b

Browse files
author
Kai
committed
update solutions
1 parent 5ed4b7f commit e6a176b

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

warmup/compare-the-triplets.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# https://www.hackerrank.com/challenges/compare-the-triplets/problem
2+
3+
#!/bin/python3
4+
5+
import os
6+
import sys
7+
8+
#
9+
# Complete the solve function below.
10+
#
11+
def solve(a0, a1, a2, b0, b1, b2):
12+
A_score = 0
13+
B_score = 0
14+
15+
a_score, b_score = get_score(a0, b0)
16+
A_score += a_score
17+
B_score += b_score
18+
19+
a_score, b_score = get_score(a1, b1)
20+
A_score += a_score
21+
B_score += b_score
22+
23+
a_score, b_score = get_score(a2, b2)
24+
A_score += a_score
25+
B_score += b_score
26+
27+
return A_score, B_score
28+
29+
30+
def get_score(a, b):
31+
a_score = 0
32+
b_score = 0
33+
if a > b:
34+
a_score = 1
35+
elif a < b:
36+
b_score = 1
37+
return a_score, b_score
38+
39+
40+
if __name__ == '__main__':
41+
f = open(os.environ['OUTPUT_PATH'], 'w')
42+
43+
a0A1A2 = input().split()
44+
45+
a0 = int(a0A1A2[0])
46+
47+
a1 = int(a0A1A2[1])
48+
49+
a2 = int(a0A1A2[2])
50+
51+
b0B1B2 = input().split()
52+
53+
b0 = int(b0B1B2[0])
54+
55+
b1 = int(b0B1B2[1])
56+
57+
b2 = int(b0B1B2[2])
58+
59+
result = solve(a0, a1, a2, b0, b1, b2)
60+
61+
f.write(' '.join(map(str, result)))
62+
f.write('\n')
63+
64+
f.close()

0 commit comments

Comments
 (0)