Swapping integers in Python

107 points · 15 comments · view on lemmy.world

15 Comments

abclop99@beehaw.org · 9 pts · 3y
a = a ^ b
b = a ^ b
a = a ^ b
Crackhappy@lemmy.world · 6 pts · 3y

Never used Python but that's hilarious.

pec@sh.itjust.works · 6 pts · 3y (2 replies)

Storing the value in the user instead of RAM!

softhat@lemmy.world · 2 pts · 3y (1 reply)

This actually raises a very good question - could you increase the amount of available RAM by using the user?

Juggling chainsaws comes to mind.

julianh@lemm.ee · 1 pts · 3y

That's basically what old games did with passwords for saves. Although I guess that's more like using the user as persistent storage rather than ram.

MyNameIsRichard@lemmy.ml · 4 pts · 3y

Using an organic processor

jnovinger@programming.dev · 3 pts · 3y (2 replies)

I raise you

@lambda _: _()
def result() -> int:
    global a; global b; a, b = b, a

hat tip to @sisyphean@programming.dev via Cursed Python

sisyphean@programming.dev · 2 pts · 3y (1 reply)

Haha thanks, but the original idea is from @goodside on Twitter, I just screenshotted his tweet and harvested the upvotes :D

jnovinger@programming.dev · 2 pts · 3y

D'oh, you're right! My bad and thanks for the catch!

pewpew@feddit.it · 3 pts · 3y (1 reply)

So you are asking the user to do it

branchial@feddit.de · 2 pts · 3y

What do you think captcha is other than computers manualizing tasks.

happyhippo@feddit.it · 2 pts · 3y

Test2

bauklotz@feddit.de · 2 pts · 3y

Version 3 is disgusting.