Skip to content

Instantly share code, notes, and snippets.

@atul-chaudhary
Created September 4, 2019 02:54
Show Gist options
  • Save atul-chaudhary/2b3ccc3f7fa01e44e54c7555773aa118 to your computer and use it in GitHub Desktop.
Save atul-chaudhary/2b3ccc3f7fa01e44e54c7555773aa118 to your computer and use it in GitHub Desktop.
HOTS : Pattern program
#pattern run for only off number like ->3,5,7,9,11 etc
#n==3
***********
* | *
* * *
*---***---*
#for n==5
*****************
* | *
* | *
* * *
* *** *
*-----*****-----*
#for n==7
***********************
* | *
* | *
* | *
* * *
* *** *
* ***** *
*-------*******-------*
#here is the program
import math
n=int(input())
for _ in range(n+n+n+2):
print('*',end='')
print()
s=math.ceil(n/2)
s1=n+math.ceil(n/2)-1
s2=n+math.ceil(n/2)-1
x=1
for i in range(1,n+1):
print('*',end='')
if(i<math.ceil(n/2)):
for _ in range(n+math.ceil(n/2)-1):
print(end=' ')
print('|',end='')
for _ in range(n+math.ceil(n/2)-1):
print(end=' ')
print('*',end='')
print()
else:
if(i>=s and i<n):
for k in range(s1):
print(end=' ')
s1-=1
for j in range(x):
print('*',end='')
x+=2
for _ in range(s2):
print(end=' ')
s2-=1
print('*',end='')
print()
else:
for _ in range(n):
print('-',end='')
for _ in range(n):
print('*',end='')
for _ in range(n):
print('-',end='')
print('*',end='')
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment