Stories
Slash Boxes
Comments
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.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • #!/usr/bin/env perl

    my @candidate = grep { $_ % 10 } 101 .. 999;
    for my $N ( 7, 9, 11 ) {
        print join( ', ',
            grep { $_ % $N == 0 && reverse( $_ ) % $N == 0 } @candidate ),
          "\n";
    }
    That's my interpretation of the spec - but that's a hell of a lot more than six numbers as you say. Is that what you get?
    • First, you need a "grep { $_ !~ /0/ }" in there. Second, I think that your three numbers, concatenated, must use each of the digits only once all together. That is, a valid answer would be qw(123 456 789) if only those numbers divided properly. qw(123 331 882) is no good.
      --
      rjbs
      • That appears to be correct. You have to read the spec carefully. They ask you to use each of those numbers, not any. I got that wrong the first time.