The goal is to swap 2 numbers. The shortest code wins.
- Temporary variables are not allowed
- You can manipulate only one variable at a time
- One of the variables may be 0
The goal is to swap 2 numbers. The shortest code wins.
|
||||
closed as unclear what you're asking by arshajii, Jan Dvorak, Paul R, Dr. belisarius, SeanC Nov 11 '13 at 13:26Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question. |
||||
Ruby, 14 bytes
13
|
||||
|
C, 17 bytes
Equivalently:
|
|||||||||||||||||||||
|
Bash, 27 bytes
In action:
|
||||
|
{a, b} = {b, a};
is not a native swap operation, but a simple list assignment. If you're going to restrict language facilities, you'd better be absolutely clear in what's allowed and what's not, and not rely on any form of user appreciation. – J B Nov 10 '13 at 15:00