- cross-posted to:
- [email protected]
- python
- cross-posted to:
- [email protected]
- python
You must log in or register to comment.
a = a ^ b b = a ^ b a = a ^ b
So you are asking the user to do it
I raise you
@lambda _: _() def result() -> int: global a; global b; a, b = b, a
hat tip to @[email protected] via Cursed Python
Haha thanks, but the original idea is from
@goodside
on Twitter, I just screenshotted his tweet and harvested the upvotes :DD’oh, you’re right! My bad and thanks for the catch!
Version 3 is disgusting.
That’s like the canonical “swap two pointers” trick