Skip to main content
4 of 5
-1
ngn
  • 15.3k
  • 2
  • 43
  • 87

APL (Dyalog Classic), 16 13 12 bytes

-3 thanks to @Adám

⍳∘≢+.×3⌽⊢+⌊/

Try it online!

⊢+⌊/ arg + min(arg)

3⌽ rotate 3 to the left, i.e. 1 to the right

+.× inner product, i.e. multiply element by element and sum

⍳∘≢ the indices of the array: 1 2 3 4 (uses 1-based indexing, ⎕io←1)

ngn
  • 15.3k
  • 2
  • 43
  • 87