Skip to content

Instantly share code, notes, and snippets.

View boazsegev's full-sized avatar
💭
Changing

Bo boazsegev

💭
Changing
View GitHub Profile
@boazsegev
boazsegev / fizbuz.c
Last active February 9, 2021 09:24
FizBuz in C - a bitwise based approach
#include <stdio.h>
#include <stdlib.h>
// calls `snprintf` with the correct fizbuz result.
//
// Note: zero modulus is questionable... but we assume it's fine.
//
// A response to Kevlin Henney's talk from 2019: https://youtu.be/SFv8Wm2HdNM
int fizzbuzz(char *dest, unsigned long dest_len, unsigned long num) {
// construct bit based result for the 4 possible states of fizbuz