Lost is a 2-D programming language where
the start position and direction of the ip are entirely random.
これは決定的な失われたプログラムを作ることを非常に困難にします。しかし、今日我々は決定論的なプログラムを書いていない、我々はRNGを書いている。
入力がなく、1桁の数字(0,1,2,3,4,5,6,7,8、または9)を出力し、すべての桁が同じ確率で出力される失われたプログラムを作成します。
Lostの開始位置と方向が唯一の乱雑さの原因であるため、これを行う唯一の方法は、ソース出力内のすべての位置に0〜9の異なる数字を出力し、それぞれの数字を出力する同じ番号にします。
あなたは -Q
フラグを使って各数字の確率を計算し、それをこのpythonスクリプトにパイプすることができます
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.
紛失の概要
失われた暗黙のIO 2D言語は、Kleinの型から多くを取ります。
ここで失われたコマンドが行うことの速いチートシートです
-
,
/
,|
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 stack -
0
–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)
81 101 bytes
これはさらにゴルフの可能性があります…
>%([email protected]>%([email protected]>%([email protected]>%([email protected]>%([email protected]>%([email protected]>%([email protected]>%([email protected]>%([email protected]>%([email protected]
^<<<<^<<<<^<<<<^<<<<^<<<<^<<<<^<<<<^<<<<^<<<<^<<<<