Sleeping Beauty problem: Difference between revisions

Content added Content deleted
(Added Quackery.)
(Added Arturo implementation)
Line 31: Line 31:





=={{header|Arturo}}==

<lang rebol>sleepingBeauty: function [reps][
wakings: 0
heads: 0
do.times: reps [
coin: random 0 1
wakings: wakings + 1
if? coin = 0 -> heads: heads + 1
else -> wakings: wakings + 1
]
print ["Wakings over" reps "repetitions =" wakings]
return 100.0 * heads//wakings
]
pc: sleepingBeauty 100000
print ["Percentage probability of heads on waking =" pc "%"]</lang>

{{out}}

<pre>Wakings over 100000 repetitions = 150096
Percentage probability of heads on waking = 33.24805457840316 %</pre>


=={{header|C++}}==
=={{header|C++}}==
Line 65: Line 88:
Sleeping Beauty should estimate a credence of: 0.333253
Sleeping Beauty should estimate a credence of: 0.333253
</pre>
</pre>



=={{header|BASIC}}==
=={{header|BASIC}}==