|
Binary Puzzle
Do any fo you techie's think you can solve this. I have about 4 hrs into it and still unsolved. No logical operators, i.e. if, else, == , ||, && , etc. ONLY binary ops as indicated in the snippit.
* bitParity - returns 1 if x contains an odd number of 0's
* Examples: bitParity(5) = 0, bitParity(7) = 1
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 20
* Rating: 4
*/
int bitParity(int x)
{
return ;
}
One more.
* sm2tc - Convert from sign-magnitude to two's complement
* where the MSB is the sign bit
* Example: sm2tc(0x80000005) = -5.
* Legal ops: ! ~ & ^ | + << >>
* Max ops: 15
* Rating: 4
*/
int sm2tc(int x)
{
return ;
}
|