aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2020-09-06 10:54:13 +0100
committerGitHub <noreply@github.com>2020-09-06 10:54:13 +0100
commit5ea3691b7602fc2d06796d77497e207be4b333b8 (patch)
treeee32b6fc77e58d27dc95fc91590b7918b4e82c10
parent5098907d82de110487e406d99b90669438f0a5e7 (diff)
parent75fa73eed1f0aba70e8be25440a5c0f90b24229d (diff)
downloadperlweeklychallenge-club-5ea3691b7602fc2d06796d77497e207be4b333b8.tar.gz
perlweeklychallenge-club-5ea3691b7602fc2d06796d77497e207be4b333b8.tar.bz2
perlweeklychallenge-club-5ea3691b7602fc2d06796d77497e207be4b333b8.zip
Merge pull request #2217 from jeongoon/ch-076
[ch-076/jeongoon] ch-2.pl code clean up; change indexing in ch-2.raku
-rw-r--r--challenge-076/jeongoon/perl/ch-2.no-getOption.pl7
-rw-r--r--challenge-076/jeongoon/perl/ch-2.pl9
-rw-r--r--challenge-076/jeongoon/raku/ch-2.raku12
3 files changed, 13 insertions, 15 deletions
diff --git a/challenge-076/jeongoon/perl/ch-2.no-getOption.pl b/challenge-076/jeongoon/perl/ch-2.no-getOption.pl
index 4816793ebc..6ad7a1f550 100644
--- a/challenge-076/jeongoon/perl/ch-2.no-getOption.pl
+++ b/challenge-076/jeongoon/perl/ch-2.no-getOption.pl
@@ -137,10 +137,9 @@ sub allSubsequencesIndices { # final summary of indices
sub genWordsOrganized {
my ( $maxPos, $lineLen, $gridString ) = @_;
- my @gridChars = split "", lc $gridString;
+ my @gridChars = split "", $gridString;
- say $gridString;
- #::dprint "[DBG] the grid string (in lower case):\n$gridString\n\n";
+ ::dprint "[DBG] the grid string (in lower case):\n$gridString\n\n";
local $" = '';
sort(
uniq( map { "@gridChars[@$_]" }
@@ -167,7 +166,7 @@ sub prepareGridData ($) {
$gdata =~ s/\n//g;
my $maxPos = (length $gdata) -1;
- $maxPos, $lineLen, (lc $gdata) # finay $gdata is in a linear form
+ $maxPos, $lineLen, (lc $gdata) # final $gdata is in a linear form
}
sub grepMatchedWordsRefWithSortedDataRef {
diff --git a/challenge-076/jeongoon/perl/ch-2.pl b/challenge-076/jeongoon/perl/ch-2.pl
index ebd275f4f4..f474f9e0ce 100644
--- a/challenge-076/jeongoon/perl/ch-2.pl
+++ b/challenge-076/jeongoon/perl/ch-2.pl
@@ -28,7 +28,7 @@ this was really heavier solution than I thought it would be.
=cut
use strict; use warnings;
-use v5.14; # state, say
+use v5.14; # say;
use Getopt::Long qw(:config gnu_compat);
use Pod::Usage;
@@ -149,10 +149,9 @@ sub allSubsequencesIndices { # final summary of indices
sub genWordsOrganized {
my ( $maxPos, $lineLen, $gridString ) = @_;
- my @gridChars = split "", lc $gridString;
+ my @gridChars = split "", $gridString;
- say $gridString;
- #::dprint "[DBG] the grid string (in lower case):\n$gridString\n\n";
+ ::dprint "[DBG] the grid string (in lower case):\n$gridString\n\n";
local $" = '';
sort(
uniq( map { "@gridChars[@$_]" }
@@ -179,7 +178,7 @@ sub prepareGridData ($) {
$gdata =~ s/\n//g;
my $maxPos = (length $gdata) -1;
- $maxPos, $lineLen, (lc $gdata) # finay $gdata is in a linear form
+ $maxPos, $lineLen, (lc $gdata) # final $gdata is in a linear form
}
sub grepMatchedWordsRefWithSortedDataRef {
diff --git a/challenge-076/jeongoon/raku/ch-2.raku b/challenge-076/jeongoon/raku/ch-2.raku
index d574c64e73..f666a4ed87 100644
--- a/challenge-076/jeongoon/raku/ch-2.raku
+++ b/challenge-076/jeongoon/raku/ch-2.raku
@@ -33,11 +33,11 @@ class GridSizeInfo {
method all-topleft-bottomright-indices {
# for every starting point: ex) |(0,1,2), |(3,6,9)
- ( |(0 ...^ $!line-len),
- |($!line-len, 2*$!line-len ... $!max-pos) ).map(
+ ( |(0 ..^ $!line-len),
+ |(1 .. $!rows-idx).map( * *$!line-len ) ).map(
-> $b {
my $col = $b % $!line-len;
- $b, |( $!line-len+1, 2*($!line-len+1) ... $!max-pos ).map(
+ $b, | (1..^$!line-len).map(* * ($!line-len+1) ).map(
-> $dt { my $p = $b + $dt;
# ex) when 0 -> 4 -> 8 -> 9(X)
( ($p <= $!max-pos) and
@@ -47,11 +47,11 @@ class GridSizeInfo {
method all-topright-bottomleft-indices {
# for every starting point: ex) |(0,1,2) |(5,8)
- ( |(0 ...^ $!line-len),
- |(2*$!line-len-1, 3*$!line-len-1 ... $!max-pos) ).map(
+ ( |(0 ..^ $!line-len),
+ |(2.. $!rows-idx+1).map( * *$!line-len -1 ) ).map(
-> $b {
my $col = $b % $!line-len;
- $b, |( $!line-len-1, 2*($!line-len-1) ... $!max-pos ).map(
+ $b, | (1 .. $col).map( * *($!line-len-1) ).map(
-> $dt { my $p = $b + $dt;
# ex) when 1 -> 3 -> 8(X)
( ($p <= $!max-pos) and