Your question is Two Number Swap. 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.
H&R Block's tax calculation code may need to exchange two intermediate integer values. Implement a function that swaps two integers without using a third variable or temporary container.
Define swap_numbers(a, b), where a and b are integers. Return a two-element tuple containing the values in swapped order: (b, a). The implementation must use only the variables a and b for the swap, aside from the function's return value. Do not use tuple unpacking, lists, dictionaries, or another temporary variable.
Use arithmetic operations to perform the swap. Python integers do not overflow, so the arithmetic approach is safe for all values within the stated constraints.
def swap_numbers(a, b):