diff options
| author | Yitzchak Scott-Thoennes <sthoenna@gmail.com> | 2025-07-04 11:59:02 -0400 |
|---|---|---|
| committer | Yitzchak Scott-Thoennes <sthoenna@gmail.com> | 2025-07-04 11:59:02 -0400 |
| commit | 357675f0c79b141c93bee605afc7adb63a503bd9 (patch) | |
| tree | b43318e4629d5c8c217b1df84c4d2fe0a7d2495b | |
| parent | 7622aed83bb2d26237532b9b757fcb2de9d65c1e (diff) | |
| download | perlweeklychallenge-club-357675f0c79b141c93bee605afc7adb63a503bd9.tar.gz perlweeklychallenge-club-357675f0c79b141c93bee605afc7adb63a503bd9.tar.bz2 perlweeklychallenge-club-357675f0c79b141c93bee605afc7adb63a503bd9.zip | |
challenge 328 task 2 python and perl solutions
| -rw-r--r-- | challenge-328/ysth/blog-2.txt | 1 | ||||
| -rw-r--r-- | challenge-328/ysth/perl/ch-2.pl | 11 | ||||
| -rw-r--r-- | challenge-328/ysth/python/ch-2.py | 14 |
3 files changed, 26 insertions, 0 deletions
diff --git a/challenge-328/ysth/blog-2.txt b/challenge-328/ysth/blog-2.txt new file mode 100644 index 0000000000..58fcc55cef --- /dev/null +++ b/challenge-328/ysth/blog-2.txt @@ -0,0 +1 @@ +https://blog.ysth.info/property-is-theft-is-good-the-weekly-challenge-328-task-2/ diff --git a/challenge-328/ysth/perl/ch-2.pl b/challenge-328/ysth/perl/ch-2.pl new file mode 100644 index 0000000000..be4f29cef9 --- /dev/null +++ b/challenge-328/ysth/perl/ch-2.pl @@ -0,0 +1,11 @@ +use 5.036; + +my @inputs = @ARGV; + +my $bad_pair = qr/(?i:(.)\1)(?<!(?=\1).)/; + +for my $string_in (@inputs) { + my $string_out = $string_in; + 1 while $string_out =~ s/$bad_pair//g; + printf "%-30s -> %-30s\n", $string_in, $string_out; +} diff --git a/challenge-328/ysth/python/ch-2.py b/challenge-328/ysth/python/ch-2.py new file mode 100644 index 0000000000..505a91e24f --- /dev/null +++ b/challenge-328/ysth/python/ch-2.py @@ -0,0 +1,14 @@ +import sys +import re + +inputs = sys.argv[1:] + +bad_pair = re.compile(r'(?i:(.)\1)(?<!\1)') + +for string_in in inputs: + string_out = string_in + while True: + string_out, substitutions_made = bad_pair.subn('', string_out) + if substitutions_made==0: + break + print(f'{string_in:<30} -> {string_out:<30}') |
