Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Revisions

7 of 8
deleted 1 character in body
Grimmy
  • 15.8k
  • 1
  • 36
  • 64

#05AB1E, (削除) 26 (削除ここまで) (削除) 24 (削除ここまで) 23 bytes

Δ©ÅA®.2ÅAo®zÅAz®nÅAt)}н

Try it online or see the steps of all test cases.

-1 byte thanks to @Grimy.

23 byter alternative for Geometric mean:

Δ©P®gzm®ÅA®zÅAz®nÅAt)}н

Try it online or see the steps of all test cases.

Explanation:

Δ # Loop until the list no longer changes:
 © # Store the current list in variable `®` (without popping)
 # (which is the implicit input-list in the first iteration)
 # Arithmetic mean:
 ÅA # Builtin to calculate the arithmetic mean of the list
 # Geometric mean:
 ®.2 # Take the base-2 logarithm of each value in the list `®`
 ÅA # Get the arithmetic mean of that list
 o # And take 2 to the power of this mean
 # Harmonic mean:
 ®z # Get 1/x for each value x in the list `®`
 ÅA # Get the arithmetic mean of that list
 z # And calculate 1/y for this mean y
 # Quadratic mean:
 ®n # Take the square of each number x in the list from the register
 ÅA # Calculate the arithmetic mean of this list
 t # And take the square-root of that mean
 ) # Wrap all four results into a list
}н # After the list no longer changes: pop and push its first value
 # (which is output implicitly as result)
Kevin Cruijssen
  • 136.2k
  • 14
  • 154
  • 394

AltStyle によって変換されたページ (->オリジナル) /