DESCRIPTION:
Write a function that when given a number >= 0, returns an Array of ascending length subarrays.
pyramid(0) => [ ]
pyramid(1) => [ [1] ]
pyramid(2) => [ [1], [1, 1] ]
pyramid(3) => [ [1], [1, 1], [1, 1, 1] ]
Note: the subarrays should be filled with 1s
def pyramid(n):
ans=[]
alist=[]
for i in range(1,n+1):
alist.append(1)
ans.append(alist.copy())
return ans
'알고리즘 문제 > CodeWar' 카테고리의 다른 글
Tic-Tac-Toe Checker (0) | 2022.10.21 |
---|---|
Not very secure (0) | 2022.10.21 |
What's a Perfect Power anyway? (0) | 2022.10.20 |
+1 Array (0) | 2022.10.20 |
The Vowel Code (0) | 2022.10.20 |