Diamond Crystal
Given an integer value N, write a program to print a diamond pattern of 2*N rows as shown below.
The first line of input is an integer N.
In the given example, the number of rows in the diamond is 2*5 = 10.
So, the output should be
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 1
5
Sample Output 1
/\
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\/
Sample Input 2
3
Sample Output 2
/\
/ \
/ \
\ /
\ /
\/
Refer to the document in the link below
https://docs.google.com/document/d/1RBknUJ-BqOf7C-5nMxEFs4JxAUQo4_KSt07SSkS3Jak/edit?usp=sharing
N = int(input('Enter integer here: '))
rows = 2 * N
for i in range(rows):
s = i + 1
if s <= N:
print((N-s)*' '+'/' +' '*i + '\\' )
else:
print((s-N-1)*' '+'\\' +' '*(rows-i-1) + '/' )
Enter integer here: 6
/\
/ \
/ \
/ \
/ \
/ \
\ /
\ /
\ /
\ /
\ /
\/
Comments
Thank you
Leave a comment