Skip to main content
added 131 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Jelly,  7  6 bytes

2ȮX$’¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)
Or see forty at once (plus a single trailing newline).

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while... ’ - ...condition: decrement V (V=2 -> 1 (truthy); V=1 -> 0 (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

Jelly,  7  6 bytes

2ȮX$’¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while... ’ - ...condition: decrement V (V=2 -> 1 (truthy); V=1 -> 0 (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

Jelly,  7  6 bytes

2ȮX$’¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)
Or see forty at once (plus a single trailing newline).

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while... ’ - ...condition: decrement V (V=2 -> 1 (truthy); V=1 -> 0 (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

deleted 1 character in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Jelly,  7  6 bytes

2ȮX$Ḋ¿2ȮX$’¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online!Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while...  - ...condition: dequeuedecrement V (V=2 -> [1]1 (truthy); V=1 -> []0 (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

Jelly,  7  6 bytes

2ȮX$Ḋ¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while...  - ...condition: dequeue V (V=2 -> [1] (truthy); V=1 -> [] (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

Jelly,  7  6 bytes

2ȮX$’¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while...  - ...condition: decrement V (V=2 -> 1 (truthy); V=1 -> 0 (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

added 415 characters in body
Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293

Jelly, 7  7  6 bytes

2ȮX$Ḋ¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while... Ḋ - ...condition: dequeue V (V=2 -> [1] (truthy); V=1 -> [] (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online!Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

Jelly, 7 bytes

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

Jelly,  7  6 bytes

2ȮX$Ḋ¿ 

A niladic Link that prints 2s as a side-effect (it also yields 1). Only prints strictly positive numbers (as allowed in the specification).

Try it online! (The footer suppresses the printing of 1 that a full program would otherwise do implicitly.)

How?

2ȮX$Ḋ¿ - Link: no arguments 2 - two - let's call this V ¿ - while... Ḋ - ...condition: dequeue V (V=2 -> [1] (truthy); V=1 -> [] (falsey)) $ - ...do: last two links as a monad - f(V): Ȯ - print V, yield V X - random integer in [1,V] -> next V = 1 or 2 (probability = 0.5) 

Previous @ 7 bytes:

2XȮß$Ị¡ 

A niladic Link that prints 1s as a side-effect (it also yields 2). This one includes the empty output (i.e. zero).

Try it online! (The footer suppresses the printing of 2 that a full program would otherwise do implicitly.)

Source Link
Jonathan Allan
  • 115.5k
  • 8
  • 68
  • 293
Loading