Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Hanoifuck is a Turing-complete programming language inspired by Towers of Hanoi and Brainfuck
unsigned char SA[1024], SB[1024], SC[1024];
unsigned char *sa = SA, *sb = SB, *sc = SC, *tmp;
int cp = 0;
int main(int argc, char **argv) {
char* code = "$+$+$+[$-!$+$+$+$+!!]![$-!!$+$+$+$+$+$+!]!!.$-$-$-.$$$$$$$+++++++..$$$+++.[$-]$+$+[$-!$+$+$+$+$+!!]!.";
while (*code != '\0') {
switch (*code) {
case '$': *++sa = 1; break;
case '+': sa[-1] = sa[-1] + *sa; sa--; break;
case '-': sa[-1] = sa[-1] - *sa; sa--; break;
case '!': tmp = sa; sa = sb; sb = sc; sc = tmp; break;
case ',': *sa = getchar(); break;
case '.': putchar(*sa); break;
case '[': if (*sa == 0) {
int bal = 1;
while (bal != 0)
switch (*++code) {
case '[': bal ++; break;
case ']': bal --; break;
default: break;
}
} break;
case ']': if (*sa != 0) {
int bal = 1;
while (bal != 0)
switch (*--code) {
case '[': bal --; break;
case ']': bal ++; break;
default: break;
}
} break;
default: break;
}
code++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.