Skip to main content
fixed attribution
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Charcoal, 10 bytes

FAFι⊞υιI‽υ

Try it online! Link is to verbose version of code. Explanation:

FA

Loop over the input numbers.

Fι⊞υι

Push each number that many times to the predefined empty list.

I‽υ

Output a random number from that list.

8 bytes using the newer version of Charcoal on ATO:

I‽ΣEAEιι

Attempt This Online! Link is to verbose version of code. Explanation:

    A       Input list
   E        Map over elements
      ι     Current element
     E      Map over implicit range
       ι    Outer element
  Σ         Flatten
 ‽          Random element
I           Cast to string
            Implicitly print

A port of @Arnauld's@JoyalMathew's JavaScript answer in straight succinct Charcoal is only 6 bytes:

I⌈∨Φθ‽

Try it online! Explanation:

    θ   Input list
   Φ    Filtered by
     ‽  Random coin flip
  ∨     If empty then implicitly use input list
 ⌈      Take the maximum
I       Cast to string
        Implicitly print

Charcoal, 10 bytes

FAFι⊞υιI‽υ

Try it online! Link is to verbose version of code. Explanation:

FA

Loop over the input numbers.

Fι⊞υι

Push each number that many times to the predefined empty list.

I‽υ

Output a random number from that list.

8 bytes using the newer version of Charcoal on ATO:

I‽ΣEAEιι

Attempt This Online! Link is to verbose version of code. Explanation:

    A       Input list
   E        Map over elements
      ι     Current element
     E      Map over implicit range
       ι    Outer element
  Σ         Flatten
 ‽          Random element
I           Cast to string
            Implicitly print

A port of @Arnauld's JavaScript answer in straight succinct Charcoal is only 6 bytes:

I⌈∨Φθ‽

Try it online! Explanation:

    θ   Input list
   Φ    Filtered by
     ‽  Random coin flip
  ∨     If empty then implicitly use input list
 ⌈      Take the maximum
I       Cast to string
        Implicitly print

Charcoal, 10 bytes

FAFι⊞υιI‽υ

Try it online! Link is to verbose version of code. Explanation:

FA

Loop over the input numbers.

Fι⊞υι

Push each number that many times to the predefined empty list.

I‽υ

Output a random number from that list.

8 bytes using the newer version of Charcoal on ATO:

I‽ΣEAEιι

Attempt This Online! Link is to verbose version of code. Explanation:

    A       Input list
   E        Map over elements
      ι     Current element
     E      Map over implicit range
       ι    Outer element
  Σ         Flatten
 ‽          Random element
I           Cast to string
            Implicitly print

A port of @JoyalMathew's JavaScript answer in straight succinct Charcoal is only 6 bytes:

I⌈∨Φθ‽

Try it online! Explanation:

    θ   Input list
   Φ    Filtered by
     ‽  Random coin flip
  ∨     If empty then implicitly use input list
 ⌈      Take the maximum
I       Cast to string
        Implicitly print
added 498 characters in body
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Charcoal, 10 bytes

FAFι⊞υιI‽υ

Try it online! Link is to verbose version of code. Explanation:

FA

Loop over the input numbers.

Fι⊞υι

Push each number that many times to the predefined empty list.

I‽υ

Output a random number from that list.

8 bytes using the newer version of Charcoal on ATO:

I‽ΣEAEιι

Attempt This Online! Link is to verbose version of code. Explanation:

    A       Input list
   E        Map over elements
      ι     Current element
     E      Map over implicit range
       ι    Outer element
  Σ         Flatten
 ‽          Random element
I           Cast to string
            Implicitly print

A port of @Arnauld's JavaScript answer in straight succinct Charcoal is only 6 bytes:

I⌈∨Φθ‽

Try it online! Explanation:

    θ   Input list
   Φ    Filtered by
     ‽  Random coin flip
  ∨     If empty then implicitly use input list
 ⌈      Take the maximum
I       Cast to string
        Implicitly print

Charcoal, 10 bytes

FAFι⊞υιI‽υ

Try it online! Link is to verbose version of code. Explanation:

FA

Loop over the input numbers.

Fι⊞υι

Push each number that many times to the predefined empty list.

I‽υ

Output a random number from that list.

8 bytes using the newer version of Charcoal on ATO:

I‽ΣEAEιι

Attempt This Online! Link is to verbose version of code. Explanation:

    A       Input list
   E        Map over elements
      ι     Current element
     E      Map over implicit range
       ι    Outer element
  Σ         Flatten
 ‽          Random element
I           Cast to string
            Implicitly print

Charcoal, 10 bytes

FAFι⊞υιI‽υ

Try it online! Link is to verbose version of code. Explanation:

FA

Loop over the input numbers.

Fι⊞υι

Push each number that many times to the predefined empty list.

I‽υ

Output a random number from that list.

8 bytes using the newer version of Charcoal on ATO:

I‽ΣEAEιι

Attempt This Online! Link is to verbose version of code. Explanation:

    A       Input list
   E        Map over elements
      ι     Current element
     E      Map over implicit range
       ι    Outer element
  Σ         Flatten
 ‽          Random element
I           Cast to string
            Implicitly print

A port of @Arnauld's JavaScript answer in straight succinct Charcoal is only 6 bytes:

I⌈∨Φθ‽

Try it online! Explanation:

    θ   Input list
   Φ    Filtered by
     ‽  Random coin flip
  ∨     If empty then implicitly use input list
 ⌈      Take the maximum
I       Cast to string
        Implicitly print
Source Link
Neil
  • 177.3k
  • 12
  • 74
  • 281

Charcoal, 10 bytes

FAFι⊞υιI‽υ

Try it online! Link is to verbose version of code. Explanation:

FA

Loop over the input numbers.

Fι⊞υι

Push each number that many times to the predefined empty list.

I‽υ

Output a random number from that list.

8 bytes using the newer version of Charcoal on ATO:

I‽ΣEAEιι

Attempt This Online! Link is to verbose version of code. Explanation:

    A       Input list
   E        Map over elements
      ι     Current element
     E      Map over implicit range
       ι    Outer element
  Σ         Flatten
 ‽          Random element
I           Cast to string
            Implicitly print