• AeonFelis@lemmy.world
    link
    fedilink
    English
    arrow-up
    10
    ·
    14 days ago

    I just use this:

    #!/bin/bash
    
    keep_generating=1
    while [[ $keep_generating == 1 ]]; do
        dd if=/dev/random of=$1 bs=1 count=$2 status=none
        echo Contents of $1 are:
        cat $1
        echo
        read -p "Try generating again? " -s -n1 answer
        while true; do
            case $answer in
                [Yy] )
                    echo
                    break
                    ;;
                [Nn] )
                    keep_generating=0
                    break
                    ;;
                *)
            esac
            read -s -n1 answer
        done
    done
    
        • thevoidzero@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          edit-2
          13 days ago

          It’s not fun when you have to explain it. But basically it is based on the infinite multiverse theory. Since the multiverse splits whenever you make choices, in this case the program would spawn a large number of multiverses each with different combinations of those bits, which means at least one of them would have the exactly the combination we want. If the program destroys the multiverse it is in after it determines it is not correct, only reality that remains is the one with correct combination of bytes. Making it that we will get the code we want on the first try.

          • AeonFelis@lemmy.world
            link
            fedilink
            English
            arrow-up
            1
            ·
            13 days ago

            You are assuming here that I know what I want. What if there is no obviously correct answer, and even in the Everett branch that generates the optimal content for the file I’ll still think it can be improved and tell it to destroy the universe?

            • thevoidzero@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              13 days ago

              I guess yeah. In that condition the algorithm would probably destroy all universe. Although you might be able to set a threshold and not destroy when it is over the threshold.

              But situation where you don’t know the answer is not for this algorithm as this one came from sorting problem.