Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- $fn = $ARGV[0];
- $ln = $ARGV[1];
- sub do_curse {
- my $n1 = shift;
- my $n2 = shift;
- my $pr = shift;
- # print "dbg: $n1 $n2 $pr\n";
- if (length($n1) == 1 && length($n2) == 1) {
- for (my $i = int($n1); $i <= int($n2); $i++) {
- print $pr . $i . "\n";
- }
- } else {
- # print "dbg2: $n1 $n2 $pr\n";
- my $a = int(substr($n1, 0, 1));
- my $b = int(substr($n2, 0, 1));
- # print "dbg3: $a $b\n";
- if ($a == $b) {
- if (length($n1) == 1) {
- $n1 .= "0";
- }
- if (length($n2) == 1) {
- $n2 .= "0";
- }
- do_curse(substr($n1, 1), substr($n2, 1), $pr . $a);
- } else {
- if (length($n1) == 1) {
- print $pr . $n1 . "\n";
- } else {
- do_curse(substr($n1, 1), "9", $pr . $a);
- }
- if ($b - $a > 1) {
- do_curse($a + 1, $b - 1, $pr);
- }
- if (length($n2) == 1) {
- print $pr . $n2 . "\n";
- } else {
- do_curse("0", substr($n2, 1), $pr . $b);
- }
- }
- }
- };
- do_curse($fn, $ln, "");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement