Skip to content

Commit 52bd1b3

Browse files
authored
Merge pull request #56 from VaradSinghal/varad_singhal
Solved day001
2 parents eeb614f + db893b0 commit 52bd1b3

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def solve():
2+
t = int(input())
3+
for _ in range(t):
4+
a, b, c = map(int, input().split())
5+
6+
d = abs(a - b)
7+
n = 2 * d
8+
9+
10+
if n == 0 or max(a, b, c) > n:
11+
print(-1)
12+
continue
13+
14+
half = n // 2
15+
16+
if c + half <= n:
17+
print(c + half)
18+
else:
19+
print(c - half)
20+
21+
solve()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def solve():
2+
t = int(input())
3+
for _ in range(t):
4+
a, b, c = map(int, input().split())
5+
6+
d = abs(a - b)
7+
n = 2 * d
8+
9+
if n == 0 or max(a, b, c) > n:
10+
print(-1)
11+
continue
12+
13+
half = n // 2
14+
15+
if c + half <= n:
16+
print(c + half)
17+
else:
18+
print(c - half)
19+
20+
# Run
21+
solve()

0 commit comments

Comments
 (0)