xxxxxxxxxx
// Another approach, that doesn't requires to create a third variable,
// but requires more computation
int a = 7;
int b = 2;
a = a ^ b;
b = a ^ b;
a = a ^ b;
// ^ means XOR
// if you want a more concise code, you can do
// a ^= b;
// b ^= a;
// a ^= b;
xxxxxxxxxx
x = 10
y = 11
x, y = y, x
"Swapping by simultaneously creating a tuple and unpacking it"
print(x, y)
xxxxxxxxxx
A = A operation B
B = A inverse-operation B
A = A inverse-operation B