Skip to content

Instantly share code, notes, and snippets.

@Lerc
Created March 24, 2012 20:19
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 Lerc/2187459 to your computer and use it in GitHub Desktop.
Save Lerc/2187459 to your computer and use it in GitHub Desktop.
A simple string unscrabler using a turing machine inside a single expression.
#include <stdio.h>
#include <setjmp.h>
int J(jmp_buf x, int y) {
longjmp(x,y);
return 0;
}
int main(int argc, char **argv)
{
jmp_buf j[011];
int x,X=0;
signed char* i = " eehcef lo u ef'oYurls " +021;
(x=setjmp(j[X++]))?J(j[x],*++i):((x=setjmp(j[X++]))?J(x[j],*--i):((x=
setjmp(j[X++]))?J(x[j],(putchar(*i),*i+=128)):(x=setjmp(j[++X]))?((x<
0)?J(1[j],5):J(2[j],3)):(x=setjmp(j[++X]))?((x>>X)?J(1[j],6):J(1[j],3
)):(x=setjmp(j[++X]))?((x&0x80)?J(1[j],7):J(1[j],5)):(x=setjmp(j[++X]
))?(((X<<5)&x)?J(1[j],4):J(2[j],X)):(x=setjmp(j[++X]))?((x&128)?J(0[j
],X):J(2[j],4)):(setjmp(j[3])>=0)?J(j[2],6):0));
getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment