Skip to main content
added 30 characters in body
Source Link
user202729
  • 17.4k
  • 2
  • 37
  • 70

To "average" a number in our array, we take take the average of itself, the number behind it, and the number ahead of it. The last number of the array assumes the number ahead of it is the first number of the array (wrapping). Do this for all but the first number of the array, it needs to stay constant. The averages should all be applied at the same time (i.e. don't take the average of a number, put it back into the array, then average the next number).

To "average" a number in our array, we take take the average of itself, the number behind it, and the number ahead of it. The last number of the array assumes the number ahead of it is the first number of the array (wrapping). Do this for all but the first number of the array, it needs to stay constant. The averages should all be applied at the same time (i.e. don't take the average of a number, put it back into the array, then average the next number).

To "average" a number in our array, we take the average of itself, the number behind it, and the number ahead of it. The last number of the array assumes the number ahead of it is the first number of the array (wrapping). Do this for all but the first number of the array, it needs to stay constant. The averages should all be applied at the same time (i.e. don't take the average of a number, put it back into the array, then average the next number).

added 62 characters in body
Source Link
  • Other mathematical methods are accepted
  • You are to assume there are at least two elements in the array
  • This is so the shortest code in bytes wins
  • Other mathematical methods are accepted
  • You are to assume there are at least two elements in the array
  • Other mathematical methods are accepted
  • You are to assume there are at least two elements in the array
  • This is so the shortest code in bytes wins
Commonmark migration
Source Link

*Array averaging

#*Array averaging ToTo "average" a number in our array, we take take the average of itself, the number behind it, and the number ahead of it. The last number of the array assumes the number ahead of it is the first number of the array (wrapping). Do this for all but the first number of the array, it needs to stay constant. The averages should all be applied at the same time (i.e. don't take the average of a number, put it back into the array, then average the next number).

#Example: ITERATION 0: [-1,4,3.5,7] 1: [-1, 2.1666666666666665, 4.833333333333333, 3.1666666666666665] 2: [-1, 2.0, 3.388888888888889, 2.3333333333333335] 3: [-1, 1.462962962962963, 2.5740740740740744, 1.5740740740740742] 4: [-1, 1.0123456790123457, 1.8703703703703705, 1.049382716049383] 5: [-1, 0.6275720164609054, 1.3106995884773662, 0.6399176954732511] 6: [-1, 0.31275720164609055, 0.8593964334705076, 0.3168724279835391] 7: [-1, 0.057384545038866065, 0.4963420210333791, 0.058756287151348875] abs(AVERAGE - FIRST_ELEMENT) = 0.903120713306 (IS LESS THAN 1) OUTPUT: 7

Example:

#Other I/O INPUT >> OUTPUT [-3, 9] >> 2 [0, 0, 0, 0] >> 0 [64, -66, -9, 78, -60] >> 29 [9, 4, 5, 3, 3, 3, 10, 1, 1, 1] >> 44 [-6, 5, -4, 3, -2, 1, -1, 2, -3, 4, -5, 6] >> 70 [100000000, 2.11, 0.0, 16.88, 8.44, 6.33, 16.88, 100000000] >> 348 [-8245, 6832, 9525, -3397, 5595, -9242, 1954, 6427, 36, -9647, -8887, 3062, -4424, -4806, -3803, 3608, -5115, -3725, -3308, -277] >> 1038

ITERATION 0: [-1,4,3.5,7]
          1: [-1, 2.1666666666666665, 4.833333333333333, 3.1666666666666665]
          2: [-1, 2.0, 3.388888888888889, 2.3333333333333335]
          3: [-1, 1.462962962962963, 2.5740740740740744, 1.5740740740740742]
          4: [-1, 1.0123456790123457, 1.8703703703703705, 1.049382716049383]
          5: [-1, 0.6275720164609054, 1.3106995884773662, 0.6399176954732511]
          6: [-1, 0.31275720164609055, 0.8593964334705076, 0.3168724279835391]
          7: [-1, 0.057384545038866065, 0.4963420210333791, 0.058756287151348875]
abs(AVERAGE - FIRST_ELEMENT) = 0.903120713306 (IS LESS THAN 1)
OUTPUT: 7

Other I/O

INPUT >> OUTPUT
[-3, 9]  >>  2
[0, 0, 0, 0]  >>  0
[64, -66, -9, 78, -60]  >>  29
[9, 4, 5, 3, 3, 3, 10, 1, 1, 1]  >>  44
[-6, 5, -4, 3, -2, 1, -1, 2, -3, 4, -5, 6]  >>  70
[100000000, 2.11, 0.0, 16.88, 8.44, 6.33, 16.88, 100000000]  >>  348
[-8245, 6832, 9525, -3397, 5595, -9242, 1954, 6427, 36, -9647, -8887, 3062, -4424, -4806, -3803, 3608, -5115, -3725, -3308, -277]  >>  1038

#Notes:

Notes:

#*Array averaging To "average" a number in our array, we take take the average of itself, the number behind it, and the number ahead of it. The last number of the array assumes the number ahead of it is the first number of the array (wrapping). Do this for all but the first number of the array, it needs to stay constant. The averages should all be applied at the same time (i.e. don't take the average of a number, put it back into the array, then average the next number).

#Example: ITERATION 0: [-1,4,3.5,7] 1: [-1, 2.1666666666666665, 4.833333333333333, 3.1666666666666665] 2: [-1, 2.0, 3.388888888888889, 2.3333333333333335] 3: [-1, 1.462962962962963, 2.5740740740740744, 1.5740740740740742] 4: [-1, 1.0123456790123457, 1.8703703703703705, 1.049382716049383] 5: [-1, 0.6275720164609054, 1.3106995884773662, 0.6399176954732511] 6: [-1, 0.31275720164609055, 0.8593964334705076, 0.3168724279835391] 7: [-1, 0.057384545038866065, 0.4963420210333791, 0.058756287151348875] abs(AVERAGE - FIRST_ELEMENT) = 0.903120713306 (IS LESS THAN 1) OUTPUT: 7

#Other I/O INPUT >> OUTPUT [-3, 9] >> 2 [0, 0, 0, 0] >> 0 [64, -66, -9, 78, -60] >> 29 [9, 4, 5, 3, 3, 3, 10, 1, 1, 1] >> 44 [-6, 5, -4, 3, -2, 1, -1, 2, -3, 4, -5, 6] >> 70 [100000000, 2.11, 0.0, 16.88, 8.44, 6.33, 16.88, 100000000] >> 348 [-8245, 6832, 9525, -3397, 5595, -9242, 1954, 6427, 36, -9647, -8887, 3062, -4424, -4806, -3803, 3608, -5115, -3725, -3308, -277] >> 1038

#Notes:

*Array averaging

To "average" a number in our array, we take take the average of itself, the number behind it, and the number ahead of it. The last number of the array assumes the number ahead of it is the first number of the array (wrapping). Do this for all but the first number of the array, it needs to stay constant. The averages should all be applied at the same time (i.e. don't take the average of a number, put it back into the array, then average the next number).

Example:

ITERATION 0: [-1,4,3.5,7]
          1: [-1, 2.1666666666666665, 4.833333333333333, 3.1666666666666665]
          2: [-1, 2.0, 3.388888888888889, 2.3333333333333335]
          3: [-1, 1.462962962962963, 2.5740740740740744, 1.5740740740740742]
          4: [-1, 1.0123456790123457, 1.8703703703703705, 1.049382716049383]
          5: [-1, 0.6275720164609054, 1.3106995884773662, 0.6399176954732511]
          6: [-1, 0.31275720164609055, 0.8593964334705076, 0.3168724279835391]
          7: [-1, 0.057384545038866065, 0.4963420210333791, 0.058756287151348875]
abs(AVERAGE - FIRST_ELEMENT) = 0.903120713306 (IS LESS THAN 1)
OUTPUT: 7

Other I/O

INPUT >> OUTPUT
[-3, 9]  >>  2
[0, 0, 0, 0]  >>  0
[64, -66, -9, 78, -60]  >>  29
[9, 4, 5, 3, 3, 3, 10, 1, 1, 1]  >>  44
[-6, 5, -4, 3, -2, 1, -1, 2, -3, 4, -5, 6]  >>  70
[100000000, 2.11, 0.0, 16.88, 8.44, 6.33, 16.88, 100000000]  >>  348
[-8245, 6832, 9525, -3397, 5595, -9242, 1954, 6427, 36, -9647, -8887, 3062, -4424, -4806, -3803, 3608, -5115, -3725, -3308, -277]  >>  1038

Notes:

fixed average
Source Link
Graviton
  • 2.9k
  • 15
  • 32
Loading
added 9 characters in body
Source Link
mbomb007
  • 23.5k
  • 7
  • 63
  • 135
Loading
fixed examples
Source Link
Graviton
  • 2.9k
  • 15
  • 32
Loading
clarified what is not in challenge
Source Link
Graviton
  • 2.9k
  • 15
  • 32
Loading
Source Link
Graviton
  • 2.9k
  • 15
  • 32
Loading