diff options
| author | Yitzchak Scott-Thoennes <sthoenna@gmail.com> | 2025-05-19 16:05:33 -0400 |
|---|---|---|
| committer | Yitzchak Scott-Thoennes <sthoenna@gmail.com> | 2025-05-19 16:24:18 -0400 |
| commit | 799aaa577a09c9a4f2d0271c5497c6ed0a839095 (patch) | |
| tree | cc3a413377da3a8bd2a2f3e535f0755f17edec2b /challenge-322 | |
| parent | 6c467a026c325f27386294744ad5d0456d6c1c50 (diff) | |
| download | perlweeklychallenge-club-799aaa577a09c9a4f2d0271c5497c6ed0a839095.tar.gz perlweeklychallenge-club-799aaa577a09c9a4f2d0271c5497c6ed0a839095.tar.bz2 perlweeklychallenge-club-799aaa577a09c9a4f2d0271c5497c6ed0a839095.zip | |
challenge 322 idiomatic perl solutions by ysth
Diffstat (limited to 'challenge-322')
| -rw-r--r-- | challenge-322/ysth/perl/README.md | 1 | ||||
| -rw-r--r-- | challenge-322/ysth/perl/ch-1.pl | 6 | ||||
| -rw-r--r-- | challenge-322/ysth/perl/ch-2.pl | 7 |
3 files changed, 14 insertions, 0 deletions
diff --git a/challenge-322/ysth/perl/README.md b/challenge-322/ysth/perl/README.md new file mode 100644 index 0000000000..60d86e8401 --- /dev/null +++ b/challenge-322/ysth/perl/README.md @@ -0,0 +1 @@ +# Solutions by Yitzchak Scott-Thoennes diff --git a/challenge-322/ysth/perl/ch-1.pl b/challenge-322/ysth/perl/ch-1.pl new file mode 100644 index 0000000000..2857d95de6 --- /dev/null +++ b/challenge-322/ysth/perl/ch-1.pl @@ -0,0 +1,6 @@ +use 5.036; + +my ($string, $group_size) = @ARGV; + +# yes, you can do this without the double reverse, but not as efficiently +say scalar reverse((reverse $string =~ y/-//dr) =~ s/.{$group_size}\K(?!\z)/-/sgr) diff --git a/challenge-322/ysth/perl/ch-2.pl b/challenge-322/ysth/perl/ch-2.pl new file mode 100644 index 0000000000..306e14aaeb --- /dev/null +++ b/challenge-322/ysth/perl/ch-2.pl @@ -0,0 +1,7 @@ +use 5.036; +use List::Util 'uniq'; + +my @integers = @ARGV; + +my @ordered = sort { $a <=> $b } uniq @integers; +say join ' ', { map(($ordered[$_-1], $_), 1..@ordered) }->@{@integers}; |
