aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xchallenge-117/perlboy1967/perl/ch-1.pl10
-rwxr-xr-xchallenge-117/perlboy1967/perl/ch-2.pl10
2 files changed, 12 insertions, 8 deletions
diff --git a/challenge-117/perlboy1967/perl/ch-1.pl b/challenge-117/perlboy1967/perl/ch-1.pl
index 0252ba108a..b268b229c6 100755
--- a/challenge-117/perlboy1967/perl/ch-1.pl
+++ b/challenge-117/perlboy1967/perl/ch-1.pl
@@ -11,14 +11,18 @@ use v5.16;
use strict;
use warnings;
-use File::Slurp;
+use File::Basename qw(dirname);
+use File::Slurp qw(read_file);
use List::MoreUtils qw(slide);
-printf "Missing row number(s) of file '%s' is/are '%s'\n", $ARGV[0], join(',',missingRows($ARGV[0]));
+my $input = $ARGV[0] // sprintf('%s/input.txt',dirname($0));
+
+printf "Missing row number(s) of file '%s' is/are '%s'\n",
+ $input, join(',',missingRows($input));
sub missingRows {
my ($f) = @_;
- return grep /\d/,slide{($a+1..$b-1)if($b-$a>1)}sort{$a<=>$b}map{chomp;s/^(\d+).*/$1/;$_}read_file($f);
+ return grep /\d/,slide{($a+1..$b-1)if($b-$a>1)}sort{$a<=>$b}map{/^(\d+).*/;$_=$1}read_file($f);
}
diff --git a/challenge-117/perlboy1967/perl/ch-2.pl b/challenge-117/perlboy1967/perl/ch-2.pl
index 19a3b62f61..a6b0a6f00f 100755
--- a/challenge-117/perlboy1967/perl/ch-2.pl
+++ b/challenge-117/perlboy1967/perl/ch-2.pl
@@ -11,11 +11,8 @@ use v5.16;
use strict;
use warnings;
-use List::Util qw(sum);
-
use Test::More;
use Test::Deep;
-use Data::Printer;
# Prototype(s)
sub findPossiblePaths($);
@@ -29,14 +26,17 @@ my %tests = (
);
foreach my $test (sort keys %tests) {
- cmp_deeply (findPossiblePaths($test),$tests{$test},"findPossiblePaths($test)");
+ cmp_deeply(findPossiblePaths($test),
+ $tests{$test},
+ "findPossiblePaths($test)");
}
done_testing;
print "Now some bigger challenges...\n";
for my $size (4 .. 10) {
- printf "findPossiblePaths($size) = %d paths\n", scalar @{findPossiblePaths($size)};
+ printf "findPossiblePaths($size) = %d paths\n",
+ scalar @{findPossiblePaths($size)};
}