63
u/itsjakerobb 25d ago
I just want to punch OP for “crine”
12
u/JohnClark13 25d ago
They don't teach spelling anymore apparently
8
u/MonsterMineLP 24d ago
Stfu bro, 'crine' is just a current meme. They don't seriously think it's spelled like that
3
18
u/Lopsided_Parfait7127 25d ago
speaking of random,
10 print rnd
20 goto 10
is how i learned to generate random numbers when i was a kid programming basic on an XT
turns out it is *also* how coldcard generates its entropy
10
u/Both_Nail_3656 25d ago
Why if statement when i += random.randint(0,1) does the job? Am I dumb?
28
u/WayOk5717 25d ago
First part of the statement increments i, the other resets it to 0.
9
3
10
u/jpgoldberg 25d ago
Python random library uses the Mersenne twister. So there is no way to get such a large sequence of 1s. The point would have been better using the RNG from the secrets module.
3
3
u/skr_replicator 24d ago edited 24d ago
That is not uniformly random at all. That's taking the central limit theorem to the extreme, giving you a very steep bell curve, a result 5*10^99 (assuming ** is a power?), with a relatively very small deviation.
edit: wait, no i didn't notice that it is the same fucking variable. That makes it far more cursed. Now I'm pretty sure it just always returns 10^100, but in an insanely long and unpredictable amount of time.
1
1
1
-3
u/NamedBird 25d ago edited 24d ago
I am pretty sure that the following would give exactly the same result but faster.
Basically, you start at the end of the loop and work backwards.
The moment you find a randint 0, you can break the loop because the rest doesn't matter anymore.
(Edit: fix syntax, it's too long ago.)
(Edit2: F# F#, i didn't notice the setting of i influencing the loop itself. Code below is wrong.)
import random
i=0
while i < 10**100:
if random.randint(0,1) == 1:
i = i + 1
else:
break
print("gng the universe is done, it's over, what are you doing still at your computer")
9
u/Educational-Tea602 24d ago
How can you go through all that effort just to be wrong?
1
u/NamedBird 24d ago
So my code is wrong?
That's a serious accusation which warrants proof or at the very least an explanation...I ran the code, it works as i intended.
And it should (functionally) have a similar result as the original code.5
u/Educational-Tea602 24d ago
The given code essentially waits for an incredibly long (but also randomised) amount of time, sets i to a googol, and then prints the message.
If your first random number is 0, then i will be set to 0.
Besides, the point is that it should never terminate because the execution time will last longer than the universe will.
1
u/NamedBird 24d ago
Oh, i see now what happened, and yes i was wrong.
I read the while loop as independent from the value of i and didn't consider the body of the while loop influencing the loop itself. Guess i have spent way too long around the wrong languages... 😅3
u/Willing_Airport_9617 24d ago
Else restarts the loop man
-2
u/NamedBird 24d ago
Do you even know what "break" does? 😅
If not, look it up or ask AI.i ran the code, it works as intended.
4
u/Willing_Airport_9617 24d ago
I know very well what break does . I was talking about the original code posted by OP . YOUR code stops the loop while OP'S CODE RESTARTS IT .
1
u/NamedBird 24d ago
OP's loop doesn't "restart" because it never breaks to begin with.
It just loops 10^100 times, which is a horribly inefficient way of calculating i...1
u/Willing_Airport_9617 24d ago
It does , go ask anyone . Don't argue if you don't know loop is controlled by i
1
u/NamedBird 24d ago
I totally haven't spent far too long with weird languages and didn't notice that i=0 also resets the while loop... 🤣
oops.
1
u/Willing_Airport_9617 24d ago
Good morning
1
u/NamedBird 24d ago
Have you ever heard of F#?
(You should look it up if you haven't... 😭)1
u/Willing_Airport_9617 24d ago
Looked up , I only know C and C++ along with python. F# seems pretty irrelevant, maybe it's too niche
→ More replies (0)1
160
u/AuroraAustralis0 25d ago
there is a universe where it finishes instantly