- #!/usr/bin/perl
- use strict;
- use warnings;
-
- use List::Util qw(sum);
- my $i=1;
- my $j=6;
- while ($i<=7) {
- my $result=sum($i++..$j++);
- print join " ",$i-1..$j-1 if 39==$result;
- }
- print "\n";
- while ($i<=12) {
- my $result=sum(1..12)-sum($i-6..$i-1);
- my @num=($i..12);
- print join " ",@num,1..6-@num if 39==$result;
- $i++;
- }
复制代码
|