Skip to content

Instantly share code, notes, and snippets.

@rodrigogiraoserrao
Last active August 6, 2020 15:13
Show Gist options
  • Save rodrigogiraoserrao/6f8912674c5285a3d3dd98ad21680a76 to your computer and use it in GitHub Desktop.
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)
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