Skip to content

Commit f069264

Browse files
authored
Add Baklava in Cython (#5155)
1 parent e1eb622 commit f069264

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

archive/c/cython/baklava.pyx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from libc.stdio cimport printf
2+
3+
4+
cdef main():
5+
cdef int n
6+
cdef int num_spaces
7+
cdef int num_stars
8+
cdef bytes buffer
9+
for n in range(-10, 11):
10+
num_spaces = abs(n)
11+
num_stars = 21 - 2 * num_spaces
12+
buffer = b" " * num_spaces + b"*" * num_stars
13+
printf(b"%s\n", buffer)
14+
15+
16+
if __name__ == "__main__":
17+
main()

0 commit comments

Comments
 (0)