Lost is a 2-D programming language where the start position and direction of the ip are entirely random.
This makes it very difficult to make deterministic Lost programs. However today we are not writing a deterministic program, we are writing an RNG.
Write a Lost program that takes no input and outputs a single digit (0,1,2,3,4,5,6,7,8, or 9), with all digits having an equal probability of being output. Since Lost's start location and direction is the only source of randomness, the only way to do this is to have every location in your source output a different number from 0 to 9 with an equal number outputting each digit.
You can calculate the probability of each digit by using the -Q
flag and piping it into this python script
import sys
a=sys.stdin.read().split()[:-1]
for x in range(10):print x,':',a.count(`x`)
print[x for x in a if x not in list("1234567890")]
This is code-golf so answers will be scored in bytes with less bytes being better.
An overview of Lost
Lost is a wrapping implicit IO 2D language taking much from the mold of Klein. Here is a quick cheatsheet of what lost commands do
\
,/
,|
Mirrors the ip<
,^
,>
,v
Points the ip in a direction[
Reflects the ip if it is moving east; becomes]
if the ip is moving horizontally]
Reflects the ip if it is moving west; becomes[
if the ip is moving horizontally!
Skips the next operation?
Pops off the top of the stack and jumps if not zero:
Duplicates the top of the stack$
Swaps the top two items of the stack(
Pops from the stack and pushes to the scope)
Pops from the scope and pushes to the stack0
-9
pushes n to the top of the stack"
Starts and ends a string literal. During a string literal commands are not run and instead their character values are pushed to the stack.+
Adds the top two numbers*
Multiplies the top two numbers-
Multiplies the top by -1%
Turns the safety off#
Turns the safety on@
Ends execution if the safety is off (starts on)
[]
act as doors,<>
point in directions and()
store and recall from the scope. Scope is used to store values. \$\endgroup\$@
or does it have other usecases? About brackets, I don't understand this part:becomes ] if the ip is moving horizontally
. Moving east is horizontally too, isn't it? \$\endgroup\$