Trapezium Order
You are given an integer N Print N rows starting from 1 in
the trapezium order as shown in the output of the below examples.
Input
The input contains an integer N.
Output
The output should have N lines.
Each of the N lines should have space-separated stegers as per the trapezium order.
Sample Input 1
4
Sample Output 1
1 2 3 4 17 18 19 20
5 6 7 14 15 16
8 9 12 13
10 11
n = int(input())
mx = n*(n+1)
lst = [i+1 for i in range(mx)]
start = 0
stop = len(lst)
for i in range(n,0,-1):
print(*(lst[start:start+i] + lst[stop-i:stop]))
start += i
sto
Comments
Leave a comment