Last active
August 6, 2020 15:13
-
-
Save rodrigogiraoserrao/6f8912674c5285a3d3dd98ad21680a76 to your computer and use it in GitHub Desktop.
RGS's solution for Problem 1, Phase 2 of 2020 APL competition (see https://mathspp.com/blog/2020-apl-competition for my thoughts on it)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DiveScore ← { | |
| (⎕IO ⎕ML ⎕WX) ← 0 1 3 | |
| ⍝ Computes the olympic dive score up to two decimal places. | |
| ⍝ Dyadic function expecting a number (dive difficulty) on the left and a vector of numbers on the right (judge scores). | |
| ⍝ ⍵ is assumed to have odd length ≥ 3. | |
| ⍝ Returns a number with, at most, 2 decimal places. | |
| ⍎2⍕⍺×1⊥ (⊂⊃⍨¨3↑(÷∘2-∘3∘≢)⌽⍋) ⍵ | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment