If you're familiar with the ? operator x ? y : z
you have to implement that in a function: int cond(int x, int y, int
z); using only ~, !, ^, &, +, |, <<, >> no if statements, or loops or
anything else, just those operators, and the function should correctly
return y or z based on the value of x. You may use constants, but only
8 bit constants. You can cast all you want. You're not supposed to use
extra variables, but in the end, it won't really matter, using
variables just makes things cleaner. You should be able to reduce your
solution to a single line in the end though that requires no extra
vars.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to