• @[email protected]
    link
    fedilink
    3
    edit-2
    46 minutes ago
    import yhwh  
    
    def interventionSort(unsortedList):
        sortedList = yhwh.pray(
        "Oh great and merciful Lord above, let thine glory shine upon yonder list!", 
        unsortedList
        )  
        return sortedList
    
  • @fluckx
    link
    163 hours ago

    I prefer the one where you randomly sorting the array until all elements are in order. ( Bogosort )

    • Ephera
      link
      fedilink
      243 hours ago

      I hear, it actually significantly increases the chance of the miracle occurring when you pass the array into multiple threads. It’s a very mysterious algorithm.

  • @[email protected]
    link
    fedilink
    726 hours ago

    My favorite is StalinSort. You go through the list and eliminate all elements which are not in line.

  • @[email protected]
    link
    fedilink
    928 hours ago

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

    • NaN
      link
      125 hours 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.

      • @[email protected]
        link
        fedilink
        43 hours ago

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

    • @[email protected]
      link
      fedilink
      658 hours ago

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

      • @[email protected]
        link
        fedilink
        337 hours 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
          link
          53 hours ago

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

          Well yeah just delete the pointer to it!

        • @[email protected]
          link
          fedilink
          217 hours ago

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

      • @[email protected]
        link
        fedilink
        138 hours ago

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

        • @db2
          link
          47 hours ago

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

    • @[email protected]
      link
      fedilink
      27 hours ago

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

    • @[email protected]
      link
      fedilink
      237 hours ago
      // portability
      

      Gave me the giggles. I’ve helped maintain systems where this portable solution would have left everyone better off.