From ebf6f4e9f1f3c685d7b06b5033fd82f355e4523d Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 18 May 2021 21:13:47 +0200 Subject: Make AWK and Perl solutions more in line --- challenge-113/abigail/awk/ch-1.awk | 6 +++--- challenge-113/abigail/perl/ch-1.pl | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/challenge-113/abigail/awk/ch-1.awk b/challenge-113/abigail/awk/ch-1.awk index 4dd17cbbe5..91923aadb6 100644 --- a/challenge-113/abigail/awk/ch-1.awk +++ b/challenge-113/abigail/awk/ch-1.awk @@ -9,7 +9,7 @@ # BEGIN { - split ("0 1 2 1 0 2 6 3 8", l) + split ("0 1 2 1 0 2 6 3 8", tens) } { @@ -20,9 +20,9 @@ BEGIN { print 1 next } - for (i = 1; i <= l [D]; i ++) { + for (i = 1; i <= tens [D]; i ++) { T = N - 10 * i - D - if ((T >= 0) && (T % D == 0)) { + if (T >= 0 && T % D == 0) { print 1 next } diff --git a/challenge-113/abigail/perl/ch-1.pl b/challenge-113/abigail/perl/ch-1.pl index bd82344f3d..51a4842116 100644 --- a/challenge-113/abigail/perl/ch-1.pl +++ b/challenge-113/abigail/perl/ch-1.pl @@ -72,6 +72,7 @@ use experimental 'lexical_subs'; my @l = ([], [], [1], [1 .. 2], [1], [], [1 .. 2], [1 .. 6], [1 .. 3], [1 .. 8]); +my @tens = (0, 0, 1, 2, 1, 0, 2, 6, 3, 8); MAIN: while (<>) { my ($N, $D) = /[0-9]+/g; @@ -80,8 +81,8 @@ MAIN: while (<>) { say 1; next MAIN; } - for my $l (@{$l [$D]}) { - my $T = $N - 10 * $l - $D; + for (my $i = 1; $i <= $tens [$D]; $i ++) { + my $T = $N - 10 * $i - $D; if ($T >= 0 && $T % $D == 0) { say 1; next MAIN; -- cgit