Build an ASCII Tower
Imagine printing a small ASCII tower directly in the console. Write tower_builder, which builds a tower with n floors and returns it as a list of strings from top to bottom. Each lower floor has two more * characters than the one above it, with spaces on the sides so the tower stays centered.
Примеры
Ввод
1Вывод
["*"]Ввод
2Вывод
[" * ", "***"]Ввод
3Вывод
[" * ", " *** ", "*****"]Нужно реализовать
def tower_builder(n: int) -> list[str]:
Теги
stringslists
Pieslēdzies, lai redzētu iesniegumu vēsturi
PieslēgtiesPieslēdzies, lai izmantotu AI mentoru
PieslēgtiesVisible tests
1
Input
1Expected
["*"]2
Input
2Expected
[" * ","***"]3
Input
3Expected
[" * "," *** ","*****"]4
Input
4Expected
[" * "," *** "," ***** ","*******"]5
Input
6Expected
[" * "," *** "," ***** "," ******* "," ********* ","***********"]6
Input
10Expected
[" * "," *** "," ***** "," ******* "," ********* "," *********** "," ************* "," *************** "," ***************** ","*******************"]Focus radio
Paused · SomaFM · Fluid