Your question is Swap Two Numbers Without Built-in. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
A Manheim vehicle-listing workflow sometimes needs to exchange two integer state values, such as source and destination positions. Implement the swap without using a temporary variable, Python tuple unpacking, or any built-in swap function.
Write a function that accepts two integers and returns them in reversed order. The input values may be positive, negative, or zero, and the function must preserve their exact values.
a and b.[b, a], produced without a third variable or tuple unpacking.You may use arithmetic operations. Python integers have arbitrary precision, so integer overflow does not need to be handled.
def swap_numbers(a, b):