Skip to content

Instantly share code, notes, and snippets.

@atul-chaudhary
Created September 4, 2019 03:07
Show Gist options
  • Save atul-chaudhary/3e5d5e512f144cd06980d73637e598fe to your computer and use it in GitHub Desktop.
Save atul-chaudhary/3e5d5e512f144cd06980d73637e598fe to your computer and use it in GitHub Desktop.
HOTS: pattern program
pattern runs for both odd and even number starting from n==3
n==3
* * * * *
* * *
* * * *
* * * * *
n==4
* * * * * *
* * *
* * * *
* * * * *
* * * * * *
n==5
* * * * * * *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
#here is the programs
n=int(input())
s=n-1
s1=n-1
for _ in range(n+2):
print('*',end=' ')
print()
for i in range(1,n+1):
print('*',end=' ')
for _ in range(s):
print(end=' ')
s-=1
for j in range(i):
print('*',end=' ')
for _ in range(s1):
print(end=' ')
s1-=1
print('*',end='')
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment