this post was submitted on 02 Sep 2024
790 points (93.4% liked)

Linux

47290 readers
783 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 10 points 2 weeks ago (1 children)

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
[–] [email protected] 5 points 2 weeks ago (1 children)

Just ask if it's correct. If not destroy the universe. Only The correct will survive, it's O(1)

[–] [email protected] 1 points 2 weeks ago (1 children)

What if there is no correct answer?

[–] [email protected] 1 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

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.

[–] [email protected] 1 points 2 weeks ago (1 children)

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?

[–] [email protected] 1 points 2 weeks 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.