Combined right angle triangle:
Sample input: 4
1st half:
1 2 3 4
5 6 7
8 9
10
2nd half:
17 18 19 20
14 15 16
12 13
11
Output should be combined pattern:
Combined pattern:
1 2 3 4 17 18 19 20
5 6 7 14 15 16
8 9 12 13
10 11
n = int(input())
print("1st half:")
tr1 = []
for i in range(n):
line = input()
row = [int(s) for s in line.split()]
tr1.append(row)
print()
print("2nd half:")
tr2 = []
for i in range(n):
line = input()
row = [int(s) for s in line.split()]
tr2.append(row)
tr = []
for i in range(n):
row = tr1[i] + tr2[i]
tr.append(row)
print("Combined pattern:")
for row in tr:
for x in row:
print(x, end=' ')
print()
Comments
Leave a comment