Baklava in C2

Published on 14 January 2025 (Updated: 14 January 2025)

Welcome to the Baklava in C2 page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

module hello_world;

import stdio as io;
import string;

public fn i32 main(i32 argc, char** argv) {
    char[22] line;
    for (u32 n = 0; n <= 20; n++) {
        u32 num_spaces = (n < 10) ? (10 - n) : (n - 10);
        u32 num_stars = 21 - 2 * num_spaces;

        // Fill line with num_spaces " "
        string.memset(line, ' ', num_spaces);

        // Append num_stars "*"
        string.memset(&line[num_spaces], '*', num_stars);

        // Null terminate line
        line[num_spaces + num_stars] = '\0';

        io.printf("%s\n", line);
    }

    return 0;
}

Baklava in C2 was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.