From b9b14d4ee20af9d8cd765b016dfeb6e8d334f647 Mon Sep 17 00:00:00 2001 From: Yashasvi Misra Date: Sun, 3 Oct 2021 13:14:57 +0000 Subject: [PATCH] Add heart-shaped-pattern --- GeeksForGeeks/issue/heart-shaped-pattern.py | 36 +++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 GeeksForGeeks/issue/heart-shaped-pattern.py diff --git a/GeeksForGeeks/issue/heart-shaped-pattern.py b/GeeksForGeeks/issue/heart-shaped-pattern.py new file mode 100644 index 00000000..7b257d4f --- /dev/null +++ b/GeeksForGeeks/issue/heart-shaped-pattern.py @@ -0,0 +1,36 @@ +n = 8 + +m = n+1 + +for i in range(n//2-1): + for j in range(m): + + if i == n//2-2 and (j == 0 or j == m-1): + print("*", end=" ") + + + elif j <= m//2 and ((i+j == n//2-3 and j <= m//4) \ + or (j-i == m//2-n//2+3 and j > m//4)): + print("*", end=" ") + + + elif j > m//2 and ((i+j == n//2-3+m//2 and j < 3*m//4) \ + or (j-i == m//2-n//2+3+m//2 and j >= 3*m//4)): + print("*", end=" ") + + + else: + print(" ", end=" ") + print() + +for i in range(n//2-1, n): + for j in range(m): + + + if (i-j == n//2-1) or (i+j == n-1+m//2): + print('*', end=" ") + + else: + print(' ', end=" ") + + print()