You should be able to solve it

You should be able to solve it

Attached: swappity.png (453x87, 10K)

ez use a const variable

x += y;
y = x - y;
x -= y

Knowing what an XOR swap is is not impressive and doesn't make you smart.
Also, here is my answer:
b = atomic_exchange(&a, b);

x, y = y, x

x ^= y ^= x ^= y

swap(x,y)

push EAX
push EBX
pop EAX
pop EBX

this gets you overflow for (x+y)>MAX_INT

xchg eax, edx

Attached: 42538000.png (960x935, 229K)

that's not an issue you retard

underrated

magic swap, the only real answer here

Doesn't matter, because you will get an underflow when you do the reverse, leaving you at the right answer.

way to many cpu clocks for that shit

>underflow
its ub and specification dependant

x = y
y = Math.random();

but interesting, would work with two's complement which is used by C and c++ IIRC

x = 1
y = 2
x = 2
y = 1

woah that was hard

[x, y] = [[0 1],[1,0]][x,y]

You cannot guarantee that this will not work when you need it to until you need it to.
a = randomVal()
b = randomVal()

>two's complement which is used by C and C++
this is also implementation dependant, but a safe assumption

x = x ^ y
y = x ^ y //y = (x ^ y ) ^ y = x ^ 0 = x
x = x ^ y //x = (x ^ y) ^ x = y ^ 0 = y

xor is outdated in sepples land
std::swap(a,b)

depends on the language

I'm only talking about C/C++. Any sane language doesn't have UB.

var a = 1;
var b = 2;
document.body.innerHTML = a+''+b;
a = parseInt(document.body.innerHTML[1]);
b = parseInt(document.body.innerHTML[0]);


You didn't say I can't use the DOM

holy shit what the fuck
let a = 1
let b = 2
[a,b] = [b,a]

the state of webdev general

Attached: 274.png (608x567, 296K)

a = 1
b = 2
permanentvariable = a
a = b
b = permanentvariable

...