diff options
| author | Yitzchak Scott-Thoennes <sthoenna@gmail.com> | 2025-07-07 17:49:13 -0400 |
|---|---|---|
| committer | Yitzchak Scott-Thoennes <sthoenna@gmail.com> | 2025-07-07 17:49:13 -0400 |
| commit | a4beda300a4a06af157d83149b160d7c0995b3e2 (patch) | |
| tree | 2946971318d9d0ac8c56891285c6e1eb89284d85 | |
| parent | bd7fce4bd5d085c209a213f2daca1e79799c9e87 (diff) | |
| download | perlweeklychallenge-club-a4beda300a4a06af157d83149b160d7c0995b3e2.tar.gz perlweeklychallenge-club-a4beda300a4a06af157d83149b160d7c0995b3e2.tar.bz2 perlweeklychallenge-club-a4beda300a4a06af157d83149b160d7c0995b3e2.zip | |
challenge 329 task 1 python and perl solutions
| -rw-r--r-- | challenge-329/ysth/blog-1.txt | 1 | ||||
| -rw-r--r-- | challenge-329/ysth/blog-2.txt | 1 | ||||
| -rw-r--r-- | challenge-329/ysth/perl/ch-1.pl | 12 | ||||
| -rw-r--r-- | challenge-329/ysth/python/ch-1.py | 10 |
4 files changed, 24 insertions, 0 deletions
diff --git a/challenge-329/ysth/blog-1.txt b/challenge-329/ysth/blog-1.txt new file mode 100644 index 0000000000..b57b7afccf --- /dev/null +++ b/challenge-329/ysth/blog-1.txt @@ -0,0 +1 @@ +https://blog.ysth.info/y-translate-the-weekly-challenge-329-task-1/ diff --git a/challenge-329/ysth/blog-2.txt b/challenge-329/ysth/blog-2.txt new file mode 100644 index 0000000000..6989dcc32c --- /dev/null +++ b/challenge-329/ysth/blog-2.txt @@ -0,0 +1 @@ +https://blog.ysth.info/not-a-nice-problem-to-have-weekly-challenge-329-task-2/ diff --git a/challenge-329/ysth/perl/ch-1.pl b/challenge-329/ysth/perl/ch-1.pl new file mode 100644 index 0000000000..4ad848af67 --- /dev/null +++ b/challenge-329/ysth/perl/ch-1.pl @@ -0,0 +1,12 @@ +use 5.036; +use JSON::XS 'encode_json'; +use List::Util 'uniq'; + +my @inputs = @ARGV; + +for my $string (@inputs) { + #my $new_string = $string =~ y/a-z/ /r; + #my @unique_integers = uniq split ' ', $new_string; + my @unique_integers = map int, uniq $string =~ /0*(\d+)/g; + printf "%-30s -> %s\n", $string, encode_json \@unique_integers; +} diff --git a/challenge-329/ysth/python/ch-1.py b/challenge-329/ysth/python/ch-1.py new file mode 100644 index 0000000000..3ec3594967 --- /dev/null +++ b/challenge-329/ysth/python/ch-1.py @@ -0,0 +1,10 @@ +import sys +import re + +inputs = sys.argv[1:] + +for string in inputs: + #new_string = string.translate({ c:' ' for c in range(ord('a'),ord('z')+1) }) + #unique_integers = sorted(set(new_string.split())) + unique_integers = [int(i) for i in sorted(set(re.findall(r'0*(\d+)', string)))] + print(f'{string:<30} -> {str(unique_integers)}') |
