31 Aug
2013
31 Aug
'13
5:59 a.m.
Cute. "32-bit" is completely unnecessary. def f(x,n) : return x^(x>>n); def g(x,n) : while x>>n : x ^= x>>n; n*=2; return x; On 30-Aug-13 20:08, quad wrote:
Here is a little puzzle. I encourage not spelunking around for the answer on the Internet. ;)
Given a 32-bit unsigned integer x, and a positive integer n, let
a = XOR(x, RIGHTSHIFT(x, n))
or in C syntax
a = x ^ (x >> n)
find, if one exists, a function f such that f(a) = x. In other words, invert the operation on x, or show otherwise.
Cheers,
Robert
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com http://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun