From cdaa7bce4b63b0eae70b84326c19e5da0e855b24 Mon Sep 17 00:00:00 2001 From: mehbark Date: Thu, 12 Dec 2024 14:46:54 -0500 Subject: [PATCH] c version --- maze.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 maze.c diff --git a/maze.c b/maze.c new file mode 100644 index 0000000..f763202 --- /dev/null +++ b/maze.c @@ -0,0 +1,27 @@ +#include +#include +#include + + +#define BUF_SIZE 8192 + +int main() { + srand(time(NULL)); + + char buf[BUF_SIZE]; + + for (;;) { + for (int i = 0; i < BUF_SIZE;) { + int bits = rand(); + for (int bit_idx = 0; bit_idx < 32; bit_idx++) { + int bit = (bits >> bit_idx) & 1; + if (bit) { + buf[i++] = '/'; + } else { + buf[i++] = '\\'; + } + } + } + fwrite(buf, sizeof(char), BUF_SIZE, stdout); + } +}