The Bard's Lemmy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@0x4E4F@infosec.pub to Programmer Humor@programming.devEnglish • 8 months ago

Not my problem sort

infosec.pub

message-square
48
fedilink
606

Not my problem sort

infosec.pub

@0x4E4F@infosec.pub to Programmer Humor@programming.devEnglish • 8 months ago
message-square
48
fedilink
alert-triangle
You must log in or register to comment.
  • @BatmanAoD@programming.dev
    link
    fedilink
    117•8 months ago

    Reminds me of quantum-bogosort: randomize the list; check if it is sorted. If it is, you’re done; otherwise, destroy this universe.

    • @Zaphod@discuss.tchncs.de
      cake
      link
      fedilink
      20•8 months ago

      The creation and destruction of universes is left as an exercise to the reader

      • @BatmanAoD@programming.dev
        link
        fedilink
        4•8 months ago

        Creation is easy, assuming the many-worlds interpretation of quantum mechanics!

    • @xmunk@sh.itjust.works
      link
      fedilink
      80•8 months ago

      Guaranteed to sort the list in nearly instantaneous time and with absolutely no downsides that are capable of objecting.

      • @vithigar@lemmy.ca
        link
        fedilink
        14•8 months ago

        Except you missed a bug in the “check if it’s sorted” code and it ends up destroying every universe.

        • @db2@lemmy.world
          link
          fedilink
          5•8 months ago

          There’s a bug in it now, that’s why we’re still here.

      • @frezik@midwest.social
        link
        fedilink
        39•8 months ago

        You still have to check that it’s sorted, which is O(n).

        We’ll also assume that destroying the universe takes constant time.

        • @Benjaben@lemmy.world
          link
          fedilink
          8•8 months ago

          We’ll also assume that destroying the universe takes constant time.

          Well yeah just delete the pointer to it!

          • @PoolloverNathan@programming.dev
            link
            fedilink
            2•8 months ago

            universe.take()

        • @BatmanAoD@programming.dev
          link
          fedilink
          36•8 months ago

          In the universe where the list is sorted, it doesn’t actually matter how long the destruction takes!

          • @FiskFisk33@startrek.website
            link
            fedilink
            7•8 months ago

            amortized O(0)

      • @frezik@midwest.social
        link
        fedilink
        1•8 months ago

        deleted by creator

    • NaN
      link
      fedilink
      13•8 months ago

      Instead of destroying the universe, can we destroy prior, failed shuffle/check iterations to retain o(1)? Then we wouldn’t have to reload all of creation into RAM.

      • @BatmanAoD@programming.dev
        link
        fedilink
        6•8 months ago

        Delete prior iterations of the loop in the same timeline? I’m not sure there’s anything in quantum mechanics to permit that…

    • @SubArcticTundra@lemmy.ml
      link
      fedilink
      12•8 months ago

      What library are you using for that?

      • SkaveRat
        link
        fedilink
        10•8 months ago

        In Python you just use

        import destroy_universe
        
    • @frezik@midwest.social
      link
      fedilink
      2•8 months ago

      Since randomizing the list increases entropy, it could theoretically make your cpu cooler just before it destroys the universe.

Programmer Humor@programming.dev

!programmer_humor@programming.dev
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: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
  • 37 users / day
  • 138 users / week
  • 570 users / month
  • 2.51K users / 6 months
  • 1 subscriber
  • 1.18K Posts
  • 20.9K Comments
  • Modlog
  • mods:
  • Feyter
  • adr1an
  • @BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne
  • BE: 0.18.2
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org