Skip to content

Instantly share code, notes, and snippets.

Created November 13, 2013 10:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/7446622 to your computer and use it in GitHub Desktop.
Save anonymous/7446622 to your computer and use it in GitHub Desktop.
A little Nerd-Test: What does foo() do?
static int[] t = {0, 5, 1, 6, 4, 3, 2, 7};
int foo(final byte value) {
int x = value & 0xff;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x *= 0x1d;
x &= 0xff;
x >>= 5;
return t[x];
}
@joa
Copy link

joa commented Nov 13, 2013

No spoilers please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment