# Restricted average (arithmetic mean) – i.e. without obvious built-ins [closed]

### Introduction

The arithmetic mean is defined as being equal to the sum of the numerical values of each and every observation divided by the total number of observations. Symbolically, if we have a data set containing the values a1,…,an. The arithmetic mean A is defined by the formula

### Objective

The challenge here is, given a non-empty list of observations, to calculate the arithmetic mean without any built-ins for mean, sum, division, or count. All other operations are allowed, e.g. median, product, multiplication, and sequence generation.

If your language cannot process lists without knowing the number of elements it has, you may use a counting built-in for such (looping, loading, etc.) purpose only, but not for the actual computation.

### Test cases

[5]5
[1,-2]-0.5
[6,1,3]3.333333333

If your language can handle complex numbers:

[5,1+3i]3+1.5i

## closed as unclear what you're asking by Mego♦, xnor, Blue, Rɪᴋᴇʀ, NoOneIsHereMay 18 '16 at 15:17

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• This is a cut-and-dry Do X without Y challenge. – Mego May 18 '16 at 7:24
• Possible duplicate of Operations with Lists – Mego May 18 '16 at 7:25
• @Mego How can it be a dup if the other one isn't a Do X without Y? – Adám May 18 '16 at 8:11
• The core challenge is the same, and the "without Y" part doesn't significantly distinguish it. – Mego May 18 '16 at 8:12
• @Mego No the core here isn't list operations. It is alternative ways to do things. – Adám May 18 '16 at 8:14

# Pyth, 13 bytes

l@*F^L2Qhe.ek


Try it online!

Uses exponential arithmetic to replace sum and division.

Uses enumerate to find number of elements.

• Perfect, that's the type of substitutions I had in mid. – Adám May 18 '16 at 8:38

# Retina, 46 37 bytes

+x;
;x
;x
;;:x
;
x
^(x+):(\1)*x*
\$#2
`

Try it online!

It's quite a trouble not to use arithmetic...