aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRikedyP <rikedyp@gmail.com>2025-09-16 13:47:57 +0100
committerRikedyP <rikedyp@gmail.com>2025-09-16 13:47:57 +0100
commit9e6c3912c1465749f9dc5596c35fc64bc96e429c (patch)
treefc5e28bdbab7d8f7c5195fcba09150b9cba99f5d
parent59e694307f1cc13b2a240ce1e7d1e0911bb6e4de (diff)
downloadperlweeklychallenge-club-9e6c3912c1465749f9dc5596c35fc64bc96e429c.tar.gz
perlweeklychallenge-club-9e6c3912c1465749f9dc5596c35fc64bc96e429c.tar.bz2
perlweeklychallenge-club-9e6c3912c1465749f9dc5596c35fc64bc96e429c.zip
simplify generation and difference of pair products
-rw-r--r--challenge-339/richard-park/apl/MaxDiff.aplf11
1 files changed, 1 insertions, 10 deletions
diff --git a/challenge-339/richard-park/apl/MaxDiff.aplf b/challenge-339/richard-park/apl/MaxDiff.aplf
index 60e7e4e56e..4e94299dcd 100644
--- a/challenge-339/richard-park/apl/MaxDiff.aplf
+++ b/challenge-339/richard-park/apl/MaxDiff.aplf
@@ -1,18 +1,9 @@
MaxDiff←{
- _←'cmat' 'pmat'⎕CY'dfns'
- MD1←{
- {⌈/-/×/(≢⍵)2 2⍴⍵},[1 2](⍵[4 cmat≢⍵]){⍺[⍵]}⍤1 99⊢pmat 4
- }
-
- MD2←{
- ⌈/-/×/⍵[c⌷⍨⊂↑⍸(⊢≡∪)∘∊¨∘.(,⍥⊂)⍨↓c←2 cmat≢⍵]
- }
-
Pairs←{↑⊃,/i,¨¨(i←¯1↓⍳⍵)↓¨⊂⍳⍵}
MD←{
p←Pairs≢⍵ ⋄ rm←Pairs ¯2+≢⍵
- ⌈/,-/×/⍵⌷⍨⊂p,[0.5]⍤1⍤1 2⊢rm⌷⍤0 1⍤2 1⊢(⍳≢n)~⍤1⊢p
+ ⌈/,(×/⍵[p])-[1]×/⍵[rm⌷⍤0 1⍤2 1⊢(⍳≢⍵)~⍤1⊢p]
}
⍝ Tests