Skip to content

Commit

Permalink
Update butterfly_pattern.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximSmolskiy authored Jan 14, 2025
1 parent 186806c commit f00a5f7
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion graphics/butterfly_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,29 @@ def butterfly_pattern(n: int) -> str:
*****
** **
* *
>>> print(butterfly_pattern(5))
* *
** **
*** ***
**** ****
*********
**** ****
*** ***
** **
* *
"""
result = []

# Upper part
for i in range(1, n + 1):
for i in range(1, n):
left_stars = "*" * i
spaces = " " * (2 * (n - i) - 1)
right_stars = "*" * i
result.append(left_stars + spaces + right_stars)

# Middle part
result.append("*" * (2 * n - 1))

# Lower part
for i in range(n - 1, 0, -1):
left_stars = "*" * i
Expand Down

0 comments on commit f00a5f7

Please sign in to comment.