aboutsummaryrefslogtreecommitdiff
path: root/challenge-322
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-322')
-rw-r--r--challenge-322/ysth/perl/README.md1
-rw-r--r--challenge-322/ysth/perl/ch-1.pl6
-rw-r--r--challenge-322/ysth/perl/ch-2.pl7
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};