Skip to content

Commit b0e20a3

Browse files
author
shiv
committed
added sum of pairs code. Super easy
1 parent 2de1695 commit b0e20a3

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

.sum_pairs.py.swp

12 KB
Binary file not shown.

ip.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
2
2-
5 12
3-
1 2 3 7 5
4-
10 15
5-
1 2 3 4 5 6 7 8 9 10
2+
5 5 9
3+
1 2 4 5 7
4+
5 6 3 4 8
5+
2 2 3
6+
0 2
7+
1 3

sum_pairs.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# SHIV's algo for finding sum or pairs
2+
3+
'''
4+
Test input
5+
6+
2
7+
5 5 9
8+
1 2 4 5 7
9+
5 6 3 4 8
10+
2 2 3
11+
0 2
12+
1 3
13+
'''
14+
15+
tn = int(input())
16+
17+
def process(A, B, s):
18+
arr = []
19+
for a in A:
20+
for b in B:
21+
if a+b == s: arr.append((a, b))
22+
print(arr)
23+
24+
for i in range(tn):
25+
cases = list(map(int, input().split()))
26+
A = list(map(int, input().split()))
27+
B = list(map(int, input().split()))
28+
process(A, B, cases[2])

0 commit comments

Comments
 (0)