diff options
| -rw-r--r-- | challenge-339/richard-park/apl/MaxDiff.aplf | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/challenge-339/richard-park/apl/MaxDiff.aplf b/challenge-339/richard-park/apl/MaxDiff.aplf index 5c6d8e35c4..60e7e4e56e 100644 --- a/challenge-339/richard-park/apl/MaxDiff.aplf +++ b/challenge-339/richard-park/apl/MaxDiff.aplf @@ -1,21 +1,20 @@ MaxDiff←{ _←'cmat' 'pmat'⎕CY'dfns' - MD←{ + 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{⍺∘(,⍥⊂)¨⍵}¨(Pairs ¯2+≢⍵)∘{⍵∘{⍺[⍵]}¨⍺}¨(⍳5)∘~¨p←Pairs≢⍵ + ⌈/,-/×/⍵⌷⍨⊂p,[0.5]⍤1⍤1 2⊢rm⌷⍤0 1⍤2 1⊢(⍳≢n)~⍤1⊢p } - u←∪{{(⊂⍋⍵)⌷⍵}⍤1{(≢⍵)2 2⍴⍵},[1 2](⍵[4 cmat≢⍵]){⍺[⍵]}⍤1 99⊢pmat 4}n - ⍝ Tests 42≢MD 5 9 3 4 6:∘∘∘ 10≢MD 1 ¯2 3 ¯4:∘∘∘ |
