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.
  • #!/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 ),
    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?
    • Nope, not even close :) That tiny spec bears close rereading. For example, "using each of the digits 1 to 9" for 3-digit numbers means your first grep is off.

      my @candidates = grep { !/0/ } 111 ... 999;

      I also used &List::MoreUtils::uniq to pre-trim that list (since duplicate numbers are not allowed).

      Basically, you'll need a three stage process (I think). First, generate your candidate list. Second, find all three digit numbers which satisfy the reverse divisor requirement. Then construct your final list of three triples.

      And though I thought I had matched dakkar's results above, I actually have three numbers for 9 :(