Lemmy.World
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
KHTangent to Programmer Humor@lemmy.mlEnglish · 2 years ago

Swapping integers in Python

external-link
message-square
15
link
fedilink
  • cross-posted to:
  • [email protected]
  • [email protected]
107
external-link

Swapping integers in Python

KHTangent to Programmer Humor@lemmy.mlEnglish · 2 years ago
message-square
15
link
fedilink
  • cross-posted to:
  • [email protected]
  • [email protected]
alert-triangle
You must log in or # to comment.
  • abclop99@beehaw.org
    link
    fedilink
    English
    arrow-up
    9
    ·
    2 years ago
    a = a ^ b
    b = a ^ b
    a = a ^ b
    
  • Crackhappy
    link
    fedilink
    English
    arrow-up
    6
    ·
    2 years ago

    Never used Python but that’s hilarious.

  • pec@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    6
    ·
    2 years ago

    Storing the value in the user instead of RAM!

    • softhat
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      1
      ·
      2 years ago

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

      Juggling chainsaws comes to mind.

      • Julian@lemm.ee
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 years ago

        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
    link
    fedilink
    English
    arrow-up
    4
    ·
    2 years ago

    Using an organic processor

  • Jason Novinger@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 years ago

    I raise you

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

    hat tip to @[email protected] via Cursed Python

    • 𝕊𝕚𝕤𝕪𝕡𝕙𝕖𝕒𝕟@programming.dev
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      2 years ago

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

      • Jason Novinger@programming.dev
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 years ago

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

  • pewpew@feddit.it
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 years ago

    So you are asking the user to do it

    • branchial@feddit.de
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 years ago

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

  • bauklotz@feddit.de
    link
    fedilink
    English
    arrow-up
    2
    ·
    2 years ago

    Version 3 is disgusting.

  • happyhippo@feddit.it
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    2 years ago

    Test2

Programmer Humor@lemmy.ml

programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 25 users / day
  • 601 users / week
  • 2.27K users / month
  • 8.82K users / 6 months
  • 11.5K local subscribers
  • 37.1K subscribers
  • 1.41K Posts
  • 33.7K Comments
  • Modlog
  • mods:
  • AgreeableLandscape@lemmy.ml
  • cat_programmer@lemmy.ml
  • UI: 0.19.12-3-gc6677485
  • BE: 0.19.12-4-gd8445881a
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org