[Python] Simple Python iterative approach[Python] Simple Python iterative approach
🎆
Happy New Year
Week 1, 2026
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))