Well, this should really go under "Idiotic Uses for Perl that are entirely Overkill", but alas, there is no such section...

I was inspired, if you will, by Genuine Quantum Randomness. This uses the module described there.

use HotBits; my $x = new HotBits::; my $n1 = $x->request (32); my $n2 = $x->request (32); if((unpack("i*",$n1))>(unpack("i*",$n2))){print "Heads\n";}elsif((unpa +ck("i*",$n1))==(unpack("i*",$n2))){print "The coin flew out of sight, + sorry. No answer, and you're out \$0.25.\n";}else{print "Tails\n";}

Quite minimalistic. And slow. But it works. And it's random enough, I'd say.

Update: fixed the problem that merlyn mentioned. Although the chances of the numbers being equal are kinda slim :)

Another Update: With a bit of code suggested by saucepan, I've made it a bit simpler. More effective, too. Here it is:

use HotBits; my $HotBits = new HotBits::; my $val=$HotBits->request (32); $val=unpack('%32b*', $val)%2; if($val==1){print "Heads\n";}else{print "Tails\n";}

--Psi
print(pack("h*","e4f64702566756e60236c6f637560247f602265696e676021602075627c602861636b65627e2")."\n");


In reply to Wacky Happy Fun Genuine Coin Flipping Software OK! by PsionicMan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.