#C, score 5#
Works 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.
#C, score 5#
Works 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.