diff options
| author | Util <bruce.gray@acm.org> | 2024-06-15 21:44:24 -0500 |
|---|---|---|
| committer | Util <bruce.gray@acm.org> | 2024-06-15 21:44:24 -0500 |
| commit | 07d0cade68ebbc8a42107213c86e3ca9d522b9f6 (patch) | |
| tree | ae061d41c9dc0456b302d41f5cc6c99a73598559 /challenge-273 | |
| parent | 72ee76ae0df98e4c506a597210a9fb7fecc27e1c (diff) | |
| download | perlweeklychallenge-club-07d0cade68ebbc8a42107213c86e3ca9d522b9f6.tar.gz perlweeklychallenge-club-07d0cade68ebbc8a42107213c86e3ca9d522b9f6.tar.bz2 perlweeklychallenge-club-07d0cade68ebbc8a42107213c86e3ca9d522b9f6.zip | |
Add TWC 273 fixes, because last push was premature.
Diffstat (limited to 'challenge-273')
| -rwxr-xr-x | challenge-273/bruce-gray/perl/ch-1.pl | 5 | ||||
| -rw-r--r-- | challenge-273/bruce-gray/raku/ch-2.raku | 4 |
2 files changed, 3 insertions, 6 deletions
diff --git a/challenge-273/bruce-gray/perl/ch-1.pl b/challenge-273/bruce-gray/perl/ch-1.pl index 6bea8e6242..e960e955d5 100755 --- a/challenge-273/bruce-gray/perl/ch-1.pl +++ b/challenge-273/bruce-gray/perl/ch-1.pl @@ -2,11 +2,10 @@ use v5.36; use POSIX qw<lround>; -# XXX challenge-273/e-choroba/perl/ch-1.pl shows \Q !!! - sub task1 ($str, $char) { my $count =()= $str =~ m{$char}g; # Google perlsecret.pod + # Note: e-choroba adds `\Q`, to make `m{\Q$char}g`, which is technically safer. return lround( 100 * $count / length($str) ); } @@ -16,8 +15,6 @@ sub task1 ($str, $char) { # https://pubs.opengroup.org/onlinepubs/9699919799/functions/round.html # https://pubs.opengroup.org/onlinepubs/9699919799/functions/lround.html -# XXX credit lround and \Q! - my @tests = qw< perl e 25 diff --git a/challenge-273/bruce-gray/raku/ch-2.raku b/challenge-273/bruce-gray/raku/ch-2.raku index 2690b8779d..7164f516fd 100644 --- a/challenge-273/bruce-gray/raku/ch-2.raku +++ b/challenge-273/bruce-gray/raku/ch-2.raku @@ -14,12 +14,12 @@ sub task2_index_substr_cont ( $str --> Bool ) { return ! $str.substr($pos_of_first_b).contains('a'); } -# XXX credit jo-37 via ~/T/d20240614/n15.pl sub task2_single_regex ( $str --> Bool ) { # return so $str ~~ / ^ <-[b]>* b <-[a]>* $ /; # return so $str ~~ / ^ <-[b]>*: b <-[a]>*: $ /; return so $str ~~ /:r ^ <-[b]>* b <-[a]>* $ /; - # https://docs.raku.org/language/regexes#Backtracking_control + # Credit jo-37 for seeing (in Perl) that controlling backtracking could improve performance. + # Raku Ref: https://docs.raku.org/language/regexes#Backtracking_control } |
