Skip to content

Instantly share code, notes, and snippets.

@atul-chaudhary
Created September 1, 2019 12:52
Show Gist options
  • Save atul-chaudhary/adfe6a8fa5a39d13b7c638b69b222158 to your computer and use it in GitHub Desktop.
Save atul-chaudhary/adfe6a8fa5a39d13b7c638b69b222158 to your computer and use it in GitHub Desktop.
Grapecity: pattern program placement test hiring
#only runs for 1,3 and 5
#pattern is
#n==5
1
232
34543
4567654
567898765
#for n==3
1
232
34543
#here is the program some optimization can be done.
import math
n = int(input())
k = n
x = 1
for i in range(1, n + 1):
for _ in range(k):
print(end=' ')
k -= 1
if(i==1):
print(1,end='')
x+=2
print()
else:
y=i
for j in range(1,x+1):
if(j<=math.ceil(x/2)):
print(y,end='')
y+=1
y1=y
else:
if(y>x):
y-=2
print(y,end='')
y-=1
x+=2
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment