-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild Tower.py
More file actions
47 lines (36 loc) · 985 Bytes
/
Copy pathBuild Tower.py
File metadata and controls
47 lines (36 loc) · 985 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'''
6 kyu Build Tower
https://www.codewars.com/kata/576757b1df89ecf5bd00073b/train/python
Build Tower
Build Tower by the following given argument:
number of floors (integer and always greater than 0).
Tower block is represented as *
Python: return a list;
JavaScript: returns an Array;
C#: returns a string[];
PHP: returns an array;
C++: returns a vector<string>;
Haskell: returns a [String];
Ruby: returns an Array;
Lua: returns a Table;
Have fun!
for example, a tower of 3 floors looks like below
[
' * ',
' *** ',
'*****'
]
and a tower of 6 floors looks like below
[
' * ',
' *** ',
' ***** ',
' ******* ',
' ********* ',
'***********'
]
Go challenge Build Tower Advanced once you have finished this :)
https://www.codewars.com/kata/57675f3dedc6f728ee000256
'''
def tower_builder(n):
return [("*" * (i*2-1)).center(n*2-1) for i in range(1, n+1)]