Data update

This commit is contained in:
Ingy döt Net 2024-07-13 15:19:22 -07:00
parent 29a5eea0d4
commit 5c1bb7bfa9
2011 changed files with 35081 additions and 3229 deletions

View file

@ -0,0 +1,25 @@
# Output: a PRN in range(0; .)
def prn:
if . == 1 then 0
else . as $n
| (($n-1)|tostring|length) as $w
| [limit($w; inputs)] | join("") | tonumber
| if . < $n then . else ($n | prn) end
end;
def round($ndec): pow(10;$ndec) as $p | . * $p | round / $p;
# Output: {n, heads, wakings}
def sleepingBeauty:
{ n: ., wakings: 0, heads: 0 }
| reduce range(0; .n) as $i (.;
(2|prn) as $coin # heads = 0, tails = 1 say
| .wakings += 1
| if $coin == 0 then .heads += 1
else .wakings += 1
end );
1000000
| sleepingBeauty
| "Wakings over \(.n) repetitions = \(.wakings).",
"Percentage probability of heads on waking = \(100*.heads/.wakings | round(3))%"