aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <mohammad.anwar@yahoo.com>2020-09-24 15:53:35 +0100
committerMohammad S Anwar <mohammad.anwar@yahoo.com>2020-09-24 15:53:35 +0100
commitacbc3bfbc9dc7ae6212e56b6a9cb0ffe99fe11c0 (patch)
tree8e34c2add99d64b7da0e6cc0558f702da7feef22
parent7fbff60a5183798adf71920e0efa3076e82efd27 (diff)
parentd316c218ea66026c80afaf1c4481fbbdbdcaf608 (diff)
downloadperlweeklychallenge-club-acbc3bfbc9dc7ae6212e56b6a9cb0ffe99fe11c0.tar.gz
perlweeklychallenge-club-acbc3bfbc9dc7ae6212e56b6a9cb0ffe99fe11c0.tar.bz2
perlweeklychallenge-club-acbc3bfbc9dc7ae6212e56b6a9cb0ffe99fe11c0.zip
Merge branch 'jeongoon-master-079-1'
-rw-r--r--challenge-079/jeongoon/perl/ch-2.pl29
-rw-r--r--challenge-079/jeongoon/raku/ch-1.raku2
-rw-r--r--challenge-079/jeongoon/raku/ch-1.short.raku2
-rw-r--r--challenge-079/jeongoon/raku/ch-2.raku3
4 files changed, 18 insertions, 18 deletions
diff --git a/challenge-079/jeongoon/perl/ch-2.pl b/challenge-079/jeongoon/perl/ch-2.pl
index 390c4c625c..7a1882c5ba 100644
--- a/challenge-079/jeongoon/perl/ch-2.pl
+++ b/challenge-079/jeongoon/perl/ch-2.pl
@@ -30,19 +30,19 @@ perl ch-2.pl [--help] [--no-utf8] [--no-color] <N> <N> <N> [ <N>*... ]
=head1 TEST
- perl ch-2.pl --no-colour --no-utf8 2 1 4 1 2 5 6 8 2 1 3 4 8 1 3 2 9 3 7 3
- Total capacity: 50
- 9| #
- 8| # ~ ~ ~ ~ # ~ ~ ~ #
- 7| # ~ ~ ~ ~ # ~ ~ ~ # ~ #
- 6| # # ~ ~ ~ ~ # ~ ~ ~ # ~ #
- 5| # # # ~ ~ ~ ~ # ~ ~ ~ # ~ #
- 4| # ~ ~ # # # ~ ~ ~ # # ~ ~ ~ # ~ #
- 3| # ~ ~ # # # ~ ~ # # # ~ # ~ # # # #
- 2| # ~ # ~ # # # # # ~ # # # ~ # # # # # #
- 1| # # # # # # # # # # # # # # # # # # # #
- `----------------------------------------
- 2 1 4 1 2 5 6 8 2 1 3 4 8 1 3 2 9 3 7 3
+perl ch-2.pl --no-utf8 --no-color 2 1 4 1 2 5 6 8 2 1 3 4 8 1 3 2 9 3 7 3 2 1 3
+Total capacity: 53
+ 9| #
+ 8| # ~ ~ ~ ~ # ~ ~ ~ #
+ 7| # ~ ~ ~ ~ # ~ ~ ~ # ~ #
+ 6| # # ~ ~ ~ ~ # ~ ~ ~ # ~ #
+ 5| # # # ~ ~ ~ ~ # ~ ~ ~ # ~ #
+ 4| # ~ ~ # # # ~ ~ ~ # # ~ ~ ~ # ~ #
+ 3| # ~ ~ # # # ~ ~ # # # ~ # ~ # # # # ~ ~ #
+ 2| # ~ # ~ # # # # # ~ # # # ~ # # # # # # # ~ #
+ 1| # # # # # # # # # # # # # # # # # # # # # # #
+ `----------------------------------------------
+ 2 1 4 1 2 5 6 8 2 1 3 4 8 1 3 2 9 3 7 3 2 1 3
you can try with colour and utf8 option if your terminal is supported.
@@ -156,8 +156,9 @@ for ( my $x = 1; $x < @T; ) {
for (($start+1) .. ($abs_ri-1)) {
$W[$_] = $water_level - $T[$_];
}
+ ( $start, $left ) = ( $x, $T[$x] );
+ ++$x;
}
- last; # no more useful data
}
}
diff --git a/challenge-079/jeongoon/raku/ch-1.raku b/challenge-079/jeongoon/raku/ch-1.raku
index 8d2b049927..7e52b7b8e7 100644
--- a/challenge-079/jeongoon/raku/ch-1.raku
+++ b/challenge-079/jeongoon/raku/ch-1.raku
@@ -10,7 +10,6 @@ our &naive = {[+] (.base(2).indices(1).elems for ^$_[0]+1)};
# this is the rule what I found. I guess this is not bad.
sub sum-a-section ($m) {
state @K = 1, 3;
- say "{@K}";
# summation of the counts of bits between 2**(m) .. 2**(m+1)-1
@K[$m]:exists ?? @K[$m] !! ( @K[$m] = [+] (1+<$m), |@K[0..$m-1] );
}
@@ -28,7 +27,6 @@ sub count-set-bits ( UInt \N ) {
++$m while $N +>= 1;
$N = N - (1+<$m);
- say "??? {$N}";
$sum += sum-upto-power2($m);
$N == 0 ?? $sum !! $sum + $N + count-set-bits($N);
}
diff --git a/challenge-079/jeongoon/raku/ch-1.short.raku b/challenge-079/jeongoon/raku/ch-1.short.raku
index e758c706c2..034f16a8f3 100644
--- a/challenge-079/jeongoon/raku/ch-1.short.raku
+++ b/challenge-079/jeongoon/raku/ch-1.short.raku
@@ -1 +1 @@
-our &MAIN=&say∘(*%(10**9+7))∘{[+] (.base(2).indices(1).elems for ^$_[0]+1)}
+our &MAIN=&say∘(*%(10**9+7))∘{[+] (.base(2).comb.sum for ^$^i+1)}
diff --git a/challenge-079/jeongoon/raku/ch-2.raku b/challenge-079/jeongoon/raku/ch-2.raku
index c597609a3d..097a2fa55a 100644
--- a/challenge-079/jeongoon/raku/ch-2.raku
+++ b/challenge-079/jeongoon/raku/ch-2.raku
@@ -53,7 +53,8 @@ given $terri {
if ( my $right = @T[$x..*].pairs.max( *.value ) ) {
@lakes.push( .export-lake( $x+$right.key) );
}
- last; # no more useful data: finish up.
+ ( .start, .left ) = $x, @T[$x];
+ ++$x;
}
}
}