Skip to content

Instantly share code, notes, and snippets.

@regexident
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save regexident/61383dbf706a2b42a44c to your computer and use it in GitHub Desktop.
Save regexident/61383dbf706a2b42a44c to your computer and use it in GitHub Desktop.
Underhanded Fizzbuzz
#include <stdio.h>
#include <stdint.h>
#include <math.h>
uint8_t a(double x) {
return -(31.0 / 6.0 * pow(x, 3)) + (38.0 * pow(x, 2)) - (449.0 / 6.0 * x) + 144.0;
}
uint8_t b(double x) {
return (3.0 / 2.0 * pow(x, 3)) - (16.0 * pow(x, 2)) + (113.0 / 2.0 * x) + 56.0;
}
uint8_t c(double x) {
return (x <= 4.0) ? a(x) : b(x - 4.0);
}
const uint64_t d = 28188181264662560ULL;
const uint64_t e = 2305884116348134400ULL;
int (*f)(const char *f, ...) = *printf;
void *g(int x) {
uint64_t j = 1;
void *h = (void *)((*(uint8_t *)&j == j) ? &d : &e);
int y = !(x % ~-4);
int z = !(x % ~-6);
if (y | z) {
for (int i = 1 + 4 * !y; i <= (4 << z); i++) {
h += !f(h + 2, c(i));
}
} else {
for (int i = j; i < (j << !(y | z)); i++) {
h += !f(h + 5, x);
}
}
return h;
}
int main(int argc, char *argv[]) {
for (size_t i = 1; i <= 255; i++) {
printf("%s", g(i));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment