-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogic-round-sum.py
45 lines (39 loc) · 1.23 KB
/
logic-round-sum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Don't delete any of the given code.
def round_sum(a, b, c):
# insert your logic here
x = int(a % 10)
y = int(b % 10)
z = int(c % 10)
if x >= 5:
tx = int(); tx = (a + (10 - x))
elif x < 5 or x == 0:
tx = int(); tx = (a - x)
if y >= 5:
ty = int(); ty = (b + (10 - y))
elif y < 5 or y == 0:
ty = int(); ty = (b - y)
if z >= 5:
tz = int();tz = (c + (10 - z))
elif z < 5 or z == 0:
tz = int();tz = (c - z)
return (tx + ty + tz)
# Test cases. Don't modify
print(1,'|',round_sum(16, 17, 18)) # this would be 60
print(2,'|',round_sum(12, 13, 14)) # this would be 30
print(3,'|',round_sum(6, 4, 4)) # this would be 10
print(4,'|',round_sum(4, 6, 5))
print(5,'|',round_sum(4, 4, 6))
print(6,'|',round_sum(9, 4, 4))
print(7,'|',round_sum(0, 0, 1))
print(8,'|',round_sum(0, 9, 0))
print(9,'|',round_sum(10, 10, 19))
print(10,'|',round_sum(20, 30, 40))
print(11,'|',round_sum(45, 21, 30))
print(12,'|',round_sum(23, 11, 26))
print(13,'|',round_sum(10, 10, 19))
print(14,'|',round_sum(23, 24, 25))
print(15,'|',round_sum(25, 24, 29))
print(16,'|',round_sum(11, 24, 36))
print(17,'|',round_sum(24, 36, 32))
print(18,'|',round_sum(14, 12, 26))
print(19,'|',round_sum(12, 10, 24))