in reply to Wacky Happy Fun Genuine Coin Flipping Software OK!

I'd bet on tails, since in the case the two numbers are equal, you're printing Tails.

Perhaps you should fetch just one bit, and use it to flip!

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Wacky Happy Fun Genuine Coin Flipping Software OK!

Replies are listed 'Best First'.
Re: Re: Wacky Happy Fun Genuine Coin Flipping Software OK!
by PsionicMan (Beadle) on Jun 05, 2001 at 09:18 UTC
    My correction is in the original now. Thanks for the heads up on that, merlyn.

    And would anyone care to elaborate on how I might do what merlyn suggests? Would that be changing up the unpack params, or what?

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

      print "The coin flew out of sight, sorry. No answer, and you're out $0 +.25.\n";

      Seeing as you're using double quotes, won't the $0 be interpolated? I doubt this is what you intended, so you might want to consider escaping the $ or using single quotes and concatinating the newline onto the string.

      Ohh and in reply to "Well, this should really go under "Idiotic Uses for Perl that are entirely Overkill", but alas, there is no such section..." there is in fact such a section. ;)
        Ooops. Fixed it up there. What can I say... it was late last night when I did all that. :)

        And I considered putting it in Obfuscated Code, but, while it may be obfuscated in spirit, it's really just straightforeward perl. No trickery or anything.

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

      Well... (completely untested)
      use HotBits; my $x = new HotBits::; my $n1 = $x->request (1); ($n1 & 1) ? print "Heads\n" : print "Tails\n";
      Okay, I lied and just tested it, and it's giving me all heads. Maybe i'm just being lucky =-) (it's entirely more likely that I'm just being buggy)

      ~Cybercosis nemo accipere quod non merere

      Changing the unpack param to b* gives you a bit string. Unpack won't give you a list directly.

      my @array= map { qw(heads tails)[$_] } (split (//, unpack ("b*", $bits +))); print "@array";
      —John