aboutsummaryrefslogtreecommitdiff
path: root/challenge-072
diff options
context:
space:
mode:
authorMyoungjin JEON <jeongoon@gmail.com>2020-08-05 09:48:19 +1000
committerMyoungjin JEON <jeongoon@gmail.com>2020-08-05 09:48:19 +1000
commite561e80f11f136733928f5e81217d76fcb540d01 (patch)
tree47ca1af0e1c00839dcd06c8555ed196d92a6b3cd /challenge-072
parent59c8d8e8ddd53b4b482d0f075e06e3e3e52dff16 (diff)
downloadperlweeklychallenge-club-e561e80f11f136733928f5e81217d76fcb540d01.tar.gz
perlweeklychallenge-club-e561e80f11f136733928f5e81217d76fcb540d01.tar.bz2
perlweeklychallenge-club-e561e80f11f136733928f5e81217d76fcb540d01.zip
remove unused variables, lines and bugfix on ch-2.raku
Diffstat (limited to 'challenge-072')
-rw-r--r--challenge-072/jeongoon/perl/ch-1.pl13
-rw-r--r--challenge-072/jeongoon/raku/ch-2.raku6
2 files changed, 9 insertions, 10 deletions
diff --git a/challenge-072/jeongoon/perl/ch-1.pl b/challenge-072/jeongoon/perl/ch-1.pl
index dd96919611..f3ef7660f1 100644
--- a/challenge-072/jeongoon/perl/ch-1.pl
+++ b/challenge-072/jeongoon/perl/ch-1.pl
@@ -7,12 +7,10 @@ use bigint;
my $N = $ARGV[0];
if ( not defined $N ) {
- print "use default value: 10.\n";
+ warn "use default value: 10.\n";
+ $N = 10;
}
-my $e;
-
-
sub f {
return 1 if $_[0] == 1;
return $_[0] * f ($_[0]-1);
@@ -27,14 +25,14 @@ sub zero_length::f_and_count ($) {
}
sub zero_length::reduce ($) {
+ my $z = 0; # put this line here for better indention in CPerl Mode
- my $z = 0;
=pod
=> Every 10 ( 2 * 5 ) makes a zero digit in the end.
A. if find the even number count it
B: if find the the number divisible by 5
- then count how many times divisible by 5a
+ then count how many times divisible by 5
But even numbers exsists plenty which more than the numbers divisible by 5
** sorry I cannot prove it mathematically but..
@@ -45,10 +43,11 @@ sub zero_length::reduce ($) {
graphically it shows it is right.
- if A.count > B.count then ( which seems correct)
+ if A.count > B.count then (which seems correct)
sum of B.count would be how many zeros in the end of the number
=cut
+
map {
my $i = 0;
( ++$z, ++$i ) while not $_ % ( 5**($i+1) );
diff --git a/challenge-072/jeongoon/raku/ch-2.raku b/challenge-072/jeongoon/raku/ch-2.raku
index 30b59ae828..36f8c2ad48 100644
--- a/challenge-072/jeongoon/raku/ch-2.raku
+++ b/challenge-072/jeongoon/raku/ch-2.raku
@@ -8,9 +8,9 @@ sub MAIN (
Int:D $A where { $A > 0 }, #= from
Int:D $B where { $B >= $A }, #= to
) {
- my $lnum = 1;
- for $F.IO.lines -> $line {
+
+ for $F.IO.lines.kv -> $lnum, $line {
say $line if $lnum == $A fff^ $lnum++ == $B;
- last if $A == $B;
+ last if $lnum == $B;
}
}