Python SolutionsPython Solutions
🎆
Happy New Year
Week 1, 2026
All SolutionsPython Solution | BMC | Python Solutions
def firework(size):
store = []
b = '\\'
f = '|'
r = '/'
space = (size-3)//2
for i in range(size//2):
store.append(f"{" "*i}{b}{" "*space}{f}{" "*space}{r}{" "*i}")
space -= 1
for s in store: print(s)
print("-"*size)
store = store[::-1]
for s in store:
print(s[::-1])
firework(99)
Simple Python iterative approach | rud | Python Solutions
def fireworks(size: int) -> None:
# Initializing
size = size if size % 2 != 0 else size + 1
half_height: int = size // 2
lines: list[str] = []
# Drawing the top layer
for row_index in range(half_height):
outer_padding: str = " " * row_index
inner_gap: str = " " * (half_height - 1 - row_index)
lines.append(f"{outer_padding}\\{inner_gap}|{inner_gap}/")
# Drawing the middle layer
lines.append("-" * size)
# Drawing the bottom layer (ez copy paste)
for row_index in range(half_height - 1, -1, -1):
outer_padding: str = " " * row_index
inner_gap: str = " " * (half_height - 1 - row_index)
lines.append(f"{outer_padding}/{inner_gap}|{inner_gap}\\")
print("\n".join(lines))
Python Logical Approach | Alexevi | Python Solutions
def fireworks(n: int) -> None:
l = (n-1)//2
for i in range(l):
a = l-i-1
print(' '*i + '\\' + ' '*a + '|' + ' '*a + '/')
print('-'*n)
for j in range(l):
i = l-j-1
a = l-i-1
print(' '*i + '/' + ' '*a + '|' + ' '*a + '\\')
python | saim | Python Solutions
def fireworks(n):
if n % 2 == 0 or n < 1:
raise ValueError("n must be a positive odd number")
mid = n // 2
#Top half
for i in range(mid):
spaces_left = mid - i
spaces_mid = i * 2 - 1
if i == 0:
print(" " * spaces_left + "|")
else:
print(
" " * spaces_left +
"\\" +
" " * spaces_mid +
"|" +
" " * spaces_mid +
"/"
)
#Middle line
print("-" * n)
#Bottom half (mirror)
for i in reversed(range(mid)):
spaces_left = mid - i
spaces_mid = i * 2 - 1
if i == 0:
print(" " * spaces_left + "|")
else:
print(
" " * spaces_left +
"/" +
" " * spaces_mid +
"|" +
" " * spaces_mid +
"\\"
)
# Call for fireworks(99)
fireworks(99)
Fireworks : Easy Solution by Python | IbnulMisbah | Python Solutions
def fireWorks(num: int):
half = num // 2
# Upper Part :
for i in range(half):
beforeSpaces = i
middleSpaces = (half - 1) - i
print(' ' * beforeSpaces + '\\' + ' ' * middleSpaces + '|' + ' ' * middleSpaces + '/')
# Middle Line :
print('-' * num)
# Lower Part :
for i in range(half - 1, -1, -1):
beforeSpaces = i
middleSpaces = (half - 1) - i
print(' ' * beforeSpaces + '/' + ' ' * middleSpaces + '|' + ' ' * middleSpaces + '\\')
num = int(input('Type an odd number : '))
fireWorks(num)
Python implementation | THOMAS L | Python Solutions
//Paste your solution here if you want to share it publicly
n = int(input())
for i in range(n):
for j in range(n):
if i == n // 2:
print("-", end="")
elif j == n // 2:
print("|", end="")
elif i == j:
print("\\", end="")
elif i == n - j - 1:
print("/", end="")
else:
print(" ", end="")
print()
Pytho | AlfieJ | Python Solutions
star = 99
layer = round((star - 1)/2)
for i in range (layer):
col = layer-i-1
print(" "*i + "\\" + " "*col + "|" + " "*col + "/")
print("-"*star)
for i in range (layer):
col = layer-i-1
print(" "*col + "/" + " "*i + "|" + " "*i + "\\")
python | JustinJ | Python Solutions
def fireworks(n):
rows = (n - 1) // 2
for i in range(rows):
spaces_out = i
spaces_in = rows - i - 1
print(" " * spaces_out + "\\" + " " * spaces_in + "|" + " " * spaces_in + "/")
print("-" * n)
for i in reversed(range(rows)):
spaces_out = i
spaces_in = rows - i - 1
print(" " * spaces_out + "/" + " " * spaces_in + "|" + " " * spaces_in + "\\")
fireworks(99)