aboutsummaryrefslogtreecommitdiff
path: root/challenge-322/wlmb/perl/ch-2.pl
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-322/wlmb/perl/ch-2.pl')
-rwxr-xr-xchallenge-322/wlmb/perl/ch-2.pl15
1 files changed, 15 insertions, 0 deletions
diff --git a/challenge-322/wlmb/perl/ch-2.pl b/challenge-322/wlmb/perl/ch-2.pl
new file mode 100755
index 0000000000..f53115ba56
--- /dev/null
+++ b/challenge-322/wlmb/perl/ch-2.pl
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+# Perl weekly challenge 322
+# Task 2: Rank Array
+#
+# See https://wlmb.github.io/2025/05/19/PWC322/#task-2-rank-array
+use v5.36;
+use List::Util qw(uniq);
+die <<~"FIN" unless @ARGV;
+ Usage: $0 N1 N2...
+ to find the ranks Ri of the numbers Ni
+ FIN
+my %rank;
+my $current=0;
+$rank{$_}=++$current for sort {$a<=>$b} uniq @ARGV;
+say "@ARGV -> @rank{@ARGV}";