From 07d0cade68ebbc8a42107213c86e3ca9d522b9f6 Mon Sep 17 00:00:00 2001 From: Util Date: Sat, 15 Jun 2024 21:44:24 -0500 Subject: Add TWC 273 fixes, because last push was premature. --- challenge-273/bruce-gray/perl/ch-1.pl | 5 +---- 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; -# 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 } -- cgit