aboutsummaryrefslogtreecommitdiff
path: root/challenge-289/asherbhs
diff options
context:
space:
mode:
authorAsher Harvey-Smith <asherharveysmith@gmail.com>2024-10-06 23:35:15 +0100
committerAsher Harvey-Smith <asherharveysmith@gmail.com>2024-10-06 23:35:15 +0100
commitb32f97d9402f129d263dce68d0ae4439d0466895 (patch)
tree1e5141d9102de1064f701429300fde2824b8e1be /challenge-289/asherbhs
parente19a3a6ba54a2b2236820f3cf878fe880e066777 (diff)
downloadperlweeklychallenge-club-b32f97d9402f129d263dce68d0ae4439d0466895.tar.gz
perlweeklychallenge-club-b32f97d9402f129d263dce68d0ae4439d0466895.tar.bz2
perlweeklychallenge-club-b32f97d9402f129d263dce68d0ae4439d0466895.zip
challenge 289
Diffstat (limited to 'challenge-289/asherbhs')
-rw-r--r--challenge-289/asherbhs/apl/ch-1.apl7
-rw-r--r--challenge-289/asherbhs/raku/ch-1.raku8
-rw-r--r--challenge-289/asherbhs/raku/ch-2.raku21
3 files changed, 36 insertions, 0 deletions
diff --git a/challenge-289/asherbhs/apl/ch-1.apl b/challenge-289/asherbhs/apl/ch-1.apl
new file mode 100644
index 0000000000..110be4724d
--- /dev/null
+++ b/challenge-289/asherbhs/apl/ch-1.apl
@@ -0,0 +1,7 @@
+⎕IO←0
+
+ThirdMaximum←(⊢⌷⍨⍋⌷⍨≢-1+2×3≤≢)∪
+
+⎕←ThirdMaximum 5 6 4 1
+⎕←ThirdMaximum 4 5
+⎕←ThirdMaximum 1 2 2 3
diff --git a/challenge-289/asherbhs/raku/ch-1.raku b/challenge-289/asherbhs/raku/ch-1.raku
new file mode 100644
index 0000000000..acab2a1b92
--- /dev/null
+++ b/challenge-289/asherbhs/raku/ch-1.raku
@@ -0,0 +1,8 @@
+sub third-maximum(Int:D @ints where @ints ≥ 1 --> Int:D) {
+ @ints.unique.sort(&[Rcmp])[{$_ ≥ 3 ?? 2 !! 0}]
+ # [ * ≥ 3 ?? 2 !! 0 ] would be nice, but alas
+}
+
+say third-maximum Array[Int](5, 6, 4, 1);
+say third-maximum Array[Int](4, 5);
+say third-maximum Array[Int](1, 2, 2, 3);
diff --git a/challenge-289/asherbhs/raku/ch-2.raku b/challenge-289/asherbhs/raku/ch-2.raku
new file mode 100644
index 0000000000..de0767c04b
--- /dev/null
+++ b/challenge-289/asherbhs/raku/ch-2.raku
@@ -0,0 +1,21 @@
+sub jumbled-letters(Str:D $text --> Str:D) {
+ $text
+ .words
+ .map({
+ my @chars = .subst(/\W/, :g).comb;
+ my @jumble = (@chars.head, |@chars[1 .. * - 2].pick(*), @chars.tail);
+ @jumble.splice: .from, 0, .Str for @$/;
+ @jumble.join
+ })
+ .join(' ')
+}
+
+say jumbled-letters 'Perl';
+say jumbled-letters "'Tisn't.";
+say jumbled-letters q:to 'END';
+ Aoccdrnig to a rscheearch at Cmabrigde Uinervtisy, it deosn’t mttaer in waht
+ oredr the ltteers in a wrod are, the olny iprmoetnt tihng is taht the frist
+ and lsat ltteer be at the rghit pclae. The rset can be a toatl mses and you
+ can sitll raed it wouthit porbelm. Tihs is bcuseae the huamn mnid deos not raed
+ ervey lteter by istlef, but the wrod as a wlohe.
+ END