Half Pyramid - 4
This Program name is Half Pyramid - 4 Write a Python program to Half Pyramid - 4
The below link contains Half Pyramid - 4 question, explanation and test cases
https://drive.google.com/file/d/1XUDbl1HqlrQ-ORm60rT22WK8MDmKxrPz/view?usp=sharing
We need exact output when the code was run
N = int(input('First input: '))
K = int(input('Second input: '))
init = 0
for k in range(1,K+1):
init = init+k
maxi = N + (init-1)
for i in range(K):
if i == 0:
print(maxi,end=' ')
else:
for j in range(1,i+2):
maxi = maxi-1
print(maxi,end=' ')
print('')
First input: 10
Second input: 5
24
23 22
21 20 19
18 17 16 15
14 13 12 11 10
First input: 1
Second input: 3
6
5 4
3 2 1
Comments
Leave a comment