diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-07-08 17:09:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-08 17:09:49 +0100 |
| commit | 5a4c615f485a9cdc6627425b1dbf5dab33a3be00 (patch) | |
| tree | 00889834543ecccc5dffa290aa73a54bd24cdd95 | |
| parent | 7f90f31f14e1fc23b2be25498fde469f95eed51b (diff) | |
| parent | a4beda300a4a06af157d83149b160d7c0995b3e2 (diff) | |
| download | perlweeklychallenge-club-5a4c615f485a9cdc6627425b1dbf5dab33a3be00.tar.gz perlweeklychallenge-club-5a4c615f485a9cdc6627425b1dbf5dab33a3be00.tar.bz2 perlweeklychallenge-club-5a4c615f485a9cdc6627425b1dbf5dab33a3be00.zip | |
Merge pull request #12310 from ysth/challenge-329-ysth
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)}') |
