Skip to content

Instantly share code, notes, and snippets.

@snapbug
Created August 16, 2011 09:53
Show Gist options
  • Select an option

  • Save snapbug/1148751 to your computer and use it in GitHub Desktop.

Select an option

Save snapbug/1148751 to your computer and use it in GitHub Desktop.
Miniature Search Engine
#include <string.h>
#include <sys/mman.h>
int main(void) {
for(char *x = (char *)mmap(0, 313805393, 2, 2, open("wsj.idx", 2), 0), i[sizeof(unsigned)], j[sizeof(unsigned)], q[256], *t, *r; t && r && *((unsigned *)&i) < *((unsigned *)r + 5) ?: (*((unsigned *)&i) = 0, t = strtok(gets(q), " '\n"), r = !t ?: (char *)bsearch(t, (unsigned *)x + 2 + 6 * *(unsigned *)x, *((unsigned *)x + 1), 6 * sizeof(unsigned), strcmp), t) ?: (*((unsigned *)&j) != *(unsigned *)x - 1 ?: qsort((unsigned *)x + 2, *(unsigned *)x, 6 * sizeof(unsigned), strcmp), *((unsigned*)x + 2 + 6 * *((unsigned *)&j)) && *((unsigned *)&j) < *(unsigned *)x); t ? ((r ? *((unsigned *)x + 2 + 6 * *((unsigned *)x + 2 + 6 * (*(unsigned *)x + *((unsigned *)x + 1)) + 2 * *((unsigned *)&i) + *((unsigned *)r + 4))) += *((unsigned *)x + 3 + 6 * (*(unsigned *)x + *((unsigned *)x + 1)) + 2 * *((unsigned *)&i) + *((unsigned *)r + 4)) : 0), *((unsigned *)&i) += 1, *((unsigned *)&j) = *(unsigned *)x - 1) : (printf("%s\n", (char *)((unsigned *)x + 4 + 6 * *((unsigned *)&j))), *((unsigned *)&j) -= 1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment