xxxxxxxxxx
ulong interleave(uint x, uint y) pure {
ulong expand(uint a) pure {
ulong x = a;
x = ((x << 16) | x) & 0x0000ffff0000ffffuL;
x = ((x << 8) | x) & 0x00ff00ff00ff00ffuL;
x = ((x << 4) | x) & 0x0f0f0f0f0f0f0f0fuL;
x = ((x << 2) | x) & 0x3333333333333333uL;
x = ((x << 1) | x) & 0x5555555555555555uL;
return x;
}
auto x2 = expand(x);
auto y2 = expand(y);
assert(!(x2 & (y2 << 1)));
return x2 + (y2 << 1);
}
void main(string[] args) {
args ~= ["711","31"];
import std.conv, std.stdio;
writeln(interleave(to!uint(args[1]), to!uint(args[2])));
}
import std.stdio;