aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-260/deadmarshal/blog.txt1
-rw-r--r--challenge-260/deadmarshal/perl/ch-1.pl16
-rw-r--r--challenge-260/deadmarshal/perl/ch-2.pl17
3 files changed, 34 insertions, 0 deletions
diff --git a/challenge-260/deadmarshal/blog.txt b/challenge-260/deadmarshal/blog.txt
new file mode 100644
index 0000000000..90e5ecd579
--- /dev/null
+++ b/challenge-260/deadmarshal/blog.txt
@@ -0,0 +1 @@
+https://deadmarshal.blogspot.com/2024/03/twc260.html
diff --git a/challenge-260/deadmarshal/perl/ch-1.pl b/challenge-260/deadmarshal/perl/ch-1.pl
new file mode 100644
index 0000000000..684707f254
--- /dev/null
+++ b/challenge-260/deadmarshal/perl/ch-1.pl
@@ -0,0 +1,16 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use List::Util qw(uniq all);
+
+sub unique_occurences{
+ my %h;
+ $h{$_}++ foreach @{$_[0]};
+ my @values = values %h;
+ @values == (uniq @values) || 0
+}
+
+printf "%d\n",unique_occurences([1,2,2,1,1,3]);
+printf "%d\n",unique_occurences([1,2,3]);
+printf "%d\n",unique_occurences([-2,0,1,-2,1,1,0,1,-2,9]);
+
diff --git a/challenge-260/deadmarshal/perl/ch-2.pl b/challenge-260/deadmarshal/perl/ch-2.pl
new file mode 100644
index 0000000000..31d71abc0a
--- /dev/null
+++ b/challenge-260/deadmarshal/perl/ch-2.pl
@@ -0,0 +1,17 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Algorithm::Combinatorics qw(permutations);
+use List::MoreUtils qw(onlyidx uniq);
+
+sub dictionary_rank{
+ 1+onlyidx{$_ eq $_[0]}
+ sort{$a cmp $b}
+ uniq map{join'',@$_}
+ permutations([split '',$_[0]])
+}
+
+printf "%d\n",dictionary_rank('CAT');
+printf "%d\n",dictionary_rank('GOOGLE');
+printf "%d\n",dictionary_rank('SECRET');
+