Post History
Vyxal o, 5 bytes ~$"," Try it Online! I'd say this counts, because $ is quite literally "swap the top two items on the stack". Explained ~$"," ~$ # Swap the top two items, but peek inste...
Answer
#1: Initial revision
# [Vyxal](https://github.com/Vyxal/Vyxal) `o`, 5 bytes ``` ~$"," ``` [Try it Online!](https://lyxal.pythonanywhere.com?flags=o&code=~%24%22%2C%22&inputs=3%0A4&header=&footer=) I'd say this counts, because `$` is quite literally "swap the top two items on the stack". ## Explained ``` ~$"," ~$ # Swap the top two items, but peek instead of pop ", # pair and output " # pair what remains and output with the `o` flag ``` But if variables are absolutely needed: ## [Vyxal](https://github.com/Vyxal/Vyxal) `o`, 29 bytes ``` →x→y",←y→temp←x→y←temp→x←y←x" ``` [Try it Online!](https://lyxal.pythonanywhere.com?flags=o&code=%E2%86%92x%E2%86%92y%22%2C%E2%86%90y%E2%86%92temp%E2%86%90x%E2%86%92y%E2%86%90temp%E2%86%92x%E2%86%90y%E2%86%90x%22&inputs=3%0A4&header=&footer=) ## Explained ``` →x→y",←y→temp←x→y←temp→x←y←x" →x→y # put the two inputs into x and y ", # print [y, x] ←y→temp # temp = y ←x→y # y = x ←temp→x # x = temp ←y←x" # print [y, x] (now swapped) ```