Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I'm still a bit in golf mode, but here's a possibility:
    $uniq_chars = keys %{{ split /()/, $string }};
    • Odd number of elements in anonymous hash at line 5.

      It doesn't like having an odd number of characters in the string length. Looks like the basis for what I was after, so some tweaking might be in order.

      Thanks for the suggestion.

      • Oops, I forgot to turn on warnings when I ran the one-liner (told you I was in golf mode!). Actually it gives the warning even if the string has an even number of characters. Here's a variation:
        $uniq_chars = keys %{{ $string =~ /(.)()/gs }};
        • I thought I'd do a bit of benchmarking and was rather surprised at the results.

          This was the code:

          #!/usr/bin/perl -w
          use strict;

          use Benchmark qw(:all);

          my $string = "ABCDEEsdasdasdfsadfwewasdaSD";

          cmpthese(100000, {
              'foreach' => \&do_foreach,
              'map' => \&do_map,
              'split' => \&do_split,

          sub do_foreach {
              my %hash;
              foreach ( split //, $string ) { $hash{$_}=1; }
              my $uniq_chars = keys %hash;

          sub do_map {

  • I'm probably being exceptionally silly, but why would predictions based on previous draws give you better results than random numbers?
    • Theoretically they shouldn't, but if there is a set of numbers or even a sequence of numbers that persistantly appear in draws, then using them seems to have a better chance of winning small prizes.

      In all the test runs I've done so far there has only one prediction that has made a bonus+5 win, and that was from the predictions based on previous draws.

      It doesn't prove anything and I only wrote it to wile away the hours on a Sunday. But it did prove useful for learning about the sorting and other alogrith

    • It doesn't. The only thing you can maximize by analyzing previous drawings is your possible win (by choosing numbers which are not frequently played by your fellow players).
      • ...waaaait, wouldn't that only be true if there were no pattern in the numbers?

        You are what you think.
        • Patterns - Yes... but not in the numbers that are drawn but in the numbers which are chosen by other players.
          • even if there's a pattern in the numbers being drawn, it's irrelevant to trying to win more? Why wouldn't finding that pattern produce increased winnings?

            This can't be the Monty Hall problem...what's the deal?


            You are what you think.