Skip to main content
deleted 49 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

Python 3.8, 52 50 bytes

-2 bytes inspired by EasyasPi's answer.

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]%100) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we map to an integer from \$[0,99]\$ with a modulo operation.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randint(0,99)) 

Try it online!

Python 3.8, 52 50 bytes

-2 bytes inspired by EasyasPi's answer.

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]%100) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we map to an integer from \$[0,99]\$ with a modulo operation.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randint(0,99)) 

Try it online!

Python 3.8, 52 50 bytes

-2 bytes inspired by EasyasPi's answer.

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration.

import os while id:print(id:=os.urandom(1)[0]%100) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we map to an integer from \$[0,99]\$ with a modulo operation.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randint(0,99)) 

Try it online!

added 131 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

Python 3.8, 5252 50 bytes

-2 bytes inspired by EasyasPi's answer.

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]//2.56[0]%100) 

Try it online!Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we scale with floor division bymap to an integer from \$2.56\$\$[0,99]\$ with a modulo operation.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randint(0,99)) 

Try it online!

Python 3.8, 52 bytes

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]//2.56) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we scale with floor division by \$2.56\$.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randint(0,99)) 

Try it online!

Python 3.8, 52 50 bytes

-2 bytes inspired by EasyasPi's answer.

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]%100) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we map to an integer from \$[0,99]\$ with a modulo operation.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randint(0,99)) 

Try it online!

deleted 363 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164

Python 3.8, 52 bytes

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]//2.56) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we scale with floor division by \$2.56\$.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randrange=randint(0,99)) 

Try it online!

There are a few alternatives for generating the random numbers: randrange(99) could be replaced by randint(0,99) at the same length and secrets.randbelow would be two bytes longer.Try it online!

Python 3.8, 52 bytes

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]//2.56) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we scale with floor division by \$2.56\$.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randrange(99)) 

Try it online!

There are a few alternatives for generating the random numbers: randrange(99) could be replaced by randint(0,99) at the same length and secrets.randbelow would be two bytes longer.

Python 3.8, 52 bytes

Produces some integers with probability \$\frac 2 {256}\$ and some with probability \$\frac 3 {256}\$ in each iteration. Output includes a trailing .0 for each number.

import os while id:print(id:=os.urandom(1)[0]//2.56) 

Try it online!

Uses the builtin function id to avoid assigning a new variable before the loop.
os.urandom(size) returns a bytes object with size random bytes. The bytes object behaves quite similar to a list of integers, which means os.urandom(1)[0] gives a single random integer from \$[0,255]\$, which we scale with floor division by \$2.56\$.


Python 3.8, 53 bytes

Generates integers from a uniform distribution over \$[0, 99]\$.

from random import* while id:print(id:=randint(0,99)) 

Try it online!

added 334 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164
Loading
added 2 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164
Loading
added 437 characters in body
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164
Loading
Source Link
ovs
  • 61.2k
  • 3
  • 49
  • 164
Loading