Skip to main content
1 of 3
Level River St
  • 26.7k
  • 4
  • 37
  • 105

#C, score 5#

Should work up to 23, not guaranteed above that.

( ((n+4)>>2)&4 ) + n & 15

((n+4)>>2)&4 returns 4 for n>12. Add it to n and you get the right answer in the least significant 4 bits, then truncate the other bits.

Level River St
  • 26.7k
  • 4
  • 37
  • 105