SRL Archive - Other Scripts

1 in a million


mixster

2008-02-15 17:02:12

Haven't you ever wondered how bored you must be to throw hundreds of thousands of coins to get 20 in a row come up heads (that's a 1 in a million chance, more or less)? Well wonder no more, for I have the solution! Not only does it relieve the stress of getting a sore arm, but it also removes the 'remembering if the last 19 coins were heads' issue, counts how many coins were thrown and how long it took you. Never again will you come second best to that random guy who managed to throw 20 heads in a row in a few hours.


program OneInAMillion;
var
i,n,timeRunning: Integer;
heads: array[0..19] of Boolean;

function check: Boolean;
var
i: Integer;
begin
for i:= 0 to 19 do
begin
if not heads[i] then
exit;
end;
Result:= True;
end;


begin
timeRunning:= GetSystemTime;
for i:= 0 to 19 do
heads[i]:= RBool;
i:= 19;
repeat
Inc(i);
n:= i-((i div 20)*20);
heads[n]:= RBool;
if(check) then
Break;
if(heads[n]) then
Writeln('Heads')
else
Writeln('Tails');
// Sleep(1);
until(False)
timeRunning:= GetSystemTime-timeRunning;
Writeln('Well done - a '+IntToStr(Round(1/Pow(0.5,20)))+' chance just happened and you threw 10 virtual heads in a row');
Writeln('Not only that, but it only took you '+IntToStr(timeRunning)+' milliseconds');
Writeln('Also, only '+IntToStr(i)+' virtual throws were needed for the 1 in a million chance');
end.
If your pc slows down drastically when using, uncomment the sleep and it should be ok (took it out as it made it take a lot longer when testing).
I do hope to (eventually) release a 'highscore' to see who truly does have the most luck and can throw the 20 in the least dice.
Also, feel free to change anything, as throwing 20 heads in a row can take some time if you're extremely unlucky (my personal best is in 149623 throws which took 72187 milliseconds and that was after a good 20 or so runs).
Also, to speed it up, you can remove the loop writeln, though it doesn't look as good when you throw 20 (in my opinion).

silentkillerjoe

2008-02-24 16:29:20

what is this for????

malotthouse

2008-02-24 16:54:55

Well done - a 1048576 chance just happened and you threw 10 virtual heads in a row
Not only that, but it only took you 409265 milliseconds
Also, only 602389 virtual throws were needed for the 1 in a million chance
Successfully executed


that was quite interesting. and fun.

GoF

2008-02-24 17:39:30

From: silentkillerjoe
what is this for????


People like you should use this script for sodomizing themselves.

Nice script, kinda pointless, but nice.

coo too

2008-02-26 11:40:05

Nice script.

Here's a proggy:
Well done - a 1048576 chance just happened and you threw 10 virtual heads in a row
Not only that, but it only took you 445750 milliseconds
Also, only 1110420 virtual throws were needed for the 1 in a million chance

JuKKa

2008-02-26 13:15:47

Well done - a 1048576 chance just happened and you threw 10 virtual heads in a row
Not only that, but it only took you 74657 milliseconds
Also, only 158524 virtual throws were needed for the 1 in a million chance


Intresting ;)

dialeyj2

2008-06-01 21:15:28

Well done - a 1048576 chance just happened and you threw 10 virtual heads in a row
Not only that, but it only took you 145844 milliseconds
Also, only 136800 virtual throws were needed for the 1 in a million chance

I barely had enough patients to sit through that good thing i dont have to do it in real life
good script tho

Timer

2008-06-01 22:25:43

What is the point of this again?

mixster

2008-06-02 02:07:48

There is no point except to show you how much time you have to waste running random crappy scripts. Also, I wish this died, but alas the gravedigging noobs did not wish it to be so *cough*dialeyj2 *cough*

GoF

2008-06-02 06:32:12


insanomano

2008-07-26 13:00:38

Well done - a 1048576 chance just happened and you threw 10 virtual heads in a row
Not only that, but it only took you 7906 milliseconds
Also, only 20324 virtual throws were needed for the 1 in a million chance

:D:D

Esteban

2008-07-26 15:37:57

Well done - a 1048576 chance just happened and you threw 10 virtual heads in a row
Not only that, but it only took you 186203 milliseconds
Also, only 239406 virtual throws were needed for the 1 in a million chance

Timer

2008-07-26 16:36:51

Well done - a 1048576 chance just happened and you threw 10 virtual heads in a row
Not only that, but it only took you 391 milliseconds
Also, only 13620 virtual throws were needed for the 1 in a million chance

Holy $4|7!!!!!!!!

mastaraymond

2008-07-26 16:45:34

0.5^20. Big chance!

mixster

2008-07-26 18:29:04

Once again, it has been revived! And 0.5^20 technically gives you a 1 in 1048576 chance, but it's close enough to a million :)
I really should update it to spit out 20 heads in a row, but to be fair, this thread needs to die again as it's a random crappy thing from yonks ago XD