[Question]
  [
Chameleon challenges are a [bad thing](http://meta.codegolf.stackexchange.com/a/8214/13486 "I actually got the idea for this challenge after reading this post on Meta"), apparently. Too bad, chameleons are beautiful creatures. Time for a change!
![Picture of a chameleon](https://kingofwallpapers.com/chameleon/chameleon-014.jpg)
As we all know, many chameleons posses a remarkable ability to blend in with their surroundings by changing the color of their skin. Which is also the objective of this challenge.
## Challenge
Imagine a square of nine pixels. Eight pixels are the surroundings. At the center is the chameleon.
*Like this:* ![Eight gray squares around a center square.](https://i.stack.imgur.com/UI9jI.png)
The chameleon naturally tries to blend in with its surroundings. It does so by changing its color to the average of that of the surrounding pixels. So, in this case, the chameleon would change its color to ![gray](https://i.stack.imgur.com/oGpRO.png).
## Objective
Given the colors of the surrounding pixels, output the color of the chameleon.
The color of the chameleon is defined as the total of all red, green and blue in the pixels ÷ 8.
## Input
An array of color values for the eight surrounding pixels, starting at the top left and continuing clockwise, like this:
```
[[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>],[<red>,<green>,<blue>]]
```
You may choose to receive input in a different form, as long as it consists of eight triples of decimal numbers 0-255.
If you receive input in a different form, numbers must either be of a consistent length or have a non-numeric separator between them. Triples must have a separating character unless they are 0-padded to 9 digits. (E.g. `044200255044200255044200255044200255044200255044200255044200255044200255` is valid, so are `44 200 255 44 200 255 44 200 255 44 200 255 44 200 255 44 200 255 44 200 255 44 200 255` and `44?200?255$44?200?255$44?200?255$44?200?255$44?200?255$44?200?255$44?200?255$44?200?255`, but `4420025544200255442002554420025544200255442002554420025544200255` is not.)
## Output
An array / string / etc. containing the colors of the center pixel (in decimal), like this:
```
[<red>,<green>,<blue>]
```
In case you output something other than an array: Numbers must either be of a consistent length or have a non-numeric separator between them. (E.g. `044200255` is valid, so is `44 200 255`, but `44200255` is not.)
The numbers may not contain decimal points, so e.g. `44.0 200 255.0` is invalid.
### Rounding
Output must be rounded to the nearest integer. (Halves must be rounded up.) E.g., if the sum of all red is *1620*, you must output `203`, not `202` or `202.5`.
## Examples
**Pictures are for illustration only.** The middle pixel is the output, the surrounding pixels are the input.
### Input:
```
[[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200],[200,200,200]]
```
### Output:
```
[200,200,200]
```
![](https://i.stack.imgur.com/oGpRO.png)
---
### Input:
```
[[0,0,0],[255,255,255],[0,0,0],[255,255,255],[255,255,255],[0,0,0],[255,255,255],[0,0,0]]
```
### Output:
```
[128,128,128]
```
![](https://i.stack.imgur.com/uSRxp.png)
---
### Input:
```
[[0,200,200],[200,0,200],[200,200,0],[60,200,0],[200,0,200],[0,200,220],[2,200,0],[0,0,0]]
```
### Output:
```
[83,125,103]
```
![](https://i.stack.imgur.com/H3bfo.png)
---
### Input:
```
[[0,56,58],[65,0,200],[33,200,0],[60,33,0],[98,0,200],[0,28,220],[2,200,0],[99,0,5]]
```
### Output:
```
[45,65,85]
```
![](https://i.stack.imgur.com/HM0m0.png)
Submissions can be a full program or a function. Standard [I/O](http://meta.codegolf.stackexchange.com/q/2447/13486) and [loophole](http://meta.codegolf.stackexchange.com/q/1061/13486) rules apply.
  
[Answer]
## Python, 38 bytes
```
lambda l:[sum(r)+4>>3for r in zip(*l)]
```
Rounds the average (towards the nearest integer, with halves rounding up) by adding 4 to the sum, then floor-dividing by 8 via the bit-shift `>>3`.
[Answer]
# MATL, ~~8~~ 4 bytes
```
YmYo
```
[Try it online!](http://matl.tryitonline.net/#code=WW1Zbw&input=W1swIDIwMCAyMDBdO1syMDAgMCAyMDBdO1syMDAgMjAwIDBdO1s2MCAyMDAgMF07WzIwMCAwIDIwMF07WzAgMjAwIDIyMF07WzIgMjAwIDBdO1swIDAgMF1d)
*4 bytes saved thanks to beaker!*
Explanation:
```
Ym          "Get the average of each column
  Yo        "And round up
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 5 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
S+4:8
```
[Test suite](http://jelly.tryitonline.net/#code=Uys0OjgKw4figqw&input=&args=W1syMDAsMjAwLDIwMF0sWzIwMCwyMDAsMjAwXSxbMjAwLDIwMCwyMDBdLFsyMDAsMjAwLDIwMF0sWzIwMCwyMDAsMjAwXSxbMjAwLDIwMCwyMDBdLFsyMDAsMjAwLDIwMF0sWzIwMCwyMDAsMjAwXV0sW1swLDAsMF0sWzI1NSwyNTUsMjU1XSxbMCwwLDBdLFsyNTUsMjU1LDI1NV0sWzI1NSwyNTUsMjU1XSxbMCwwLDBdLFsyNTUsMjU1LDI1NV0sWzAsMCwwXV0sW1swLDIwMCwyMDBdLFsyMDAsMCwyMDBdLFsyMDAsMjAwLDBdLFs2MCwyMDAsMF0sWzIwMCwwLDIwMF0sWzAsMjAwLDIyMF0sWzIsMjAwLDBdLFswLDAsMF1d). (Slightly modified so as to verify all testcases at once.)
```
S+4:8
S      sum (vectorized)
 +4    add 4
   :8  floor division by 8
```
[Answer]
# C, ~~151~~ ~~123~~ ~~103~~ 91
Requires 24 parameters passed to the program, in the order R G B R G B ... and outputs the triplet R G B without a newline.
```
i,t;main(c,v)char**v;{for(i=0;t=4,i++<3;printf("%d ",t/8))for(c=i;c<24;c+=3)t+=atoi(v[c]);}
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 8 bytes
```
m.R.Od0C
```
[Test suite](http://pyth.herokuapp.com/?code=m.R.Od0C&test_suite=1&test_suite_input=%5B%5B200%2C200%2C200%5D%2C%5B200%2C200%2C200%5D%2C%5B200%2C200%2C200%5D%2C%5B200%2C200%2C200%5D%2C%5B200%2C200%2C200%5D%2C%5B200%2C200%2C200%5D%2C%5B200%2C200%2C200%5D%2C%5B200%2C200%2C200%5D%5D%0A%5B%5B0%2C0%2C0%5D%2C%5B255%2C255%2C255%5D%2C%5B0%2C0%2C0%5D%2C%5B255%2C255%2C255%5D%2C%5B255%2C255%2C255%5D%2C%5B0%2C0%2C0%5D%2C%5B255%2C255%2C255%5D%2C%5B0%2C0%2C0%5D%5D%0A%5B%5B0%2C200%2C200%5D%2C%5B200%2C0%2C200%5D%2C%5B200%2C200%2C0%5D%2C%5B60%2C200%2C0%5D%2C%5B200%2C0%2C200%5D%2C%5B0%2C200%2C220%5D%2C%5B2%2C200%2C0%5D%2C%5B0%2C0%2C0%5D%5D&debug=0).
```
m.R.Od0C     input: Q
m.R.Od0CQ    implicit arguments
        Q    input
       C     transpose
m    d       for each:
   .O            take average
 .R   0          round off
```
[Answer]
## Pyke, 7 bytes
```
,FsOO8f
```
[Try it here!](http://pyke.catbus.co.uk/?code=%2CFsOO8f&input=%5B%5B0%2C0%2C0%5D%2C%5B255%2C255%2C255%5D%2C%5B0%2C0%2C0%5D%2C%5B255%2C255%2C255%5D%2C%5B255%2C255%2C255%5D%2C%5B0%2C0%2C0%5D%2C%5B255%2C255%2C255%5D%2C%5B0%2C0%2C0%5D%5D)
[Answer]
# J, 11 bytes
```
0.5<.@++/%#
```
Takes the input as an 8x3 array where each row is an RGB value
## Explanation
```
0.5<.@++/%#  Input: a
          #  Count the number of rows
       +/    Sum along the columns
         %   Divide each sum by the count to get the averages
0.5   +      Add 0.5 to each average
   <.@       Floor each value and return
```
[Answer]
# JavaScript, ~~75~~ ~~64~~ 55 bytes
```
a=>a.reduce((p,c)=>p.map((e,i)=>e+c[i])).map(x=>x+4>>3)
```
A JavaScript answer to get you started.
**Edit:** Saved 11 bytes thanks to [Dendrobium](https://codegolf.stackexchange.com/users/20519/dendrobium), and another 9 thanks to [Neil](https://codegolf.stackexchange.com/users/17602/neil).
[Answer]
# Lisp - 180 179 bytes
EDIT: Formatted for further golfing.
```
(defun a(l)(/(apply #'+ l)(length l)))(defun r(a)(if(integerp(* a 2))(ceiling a)(round a)))(defun c(s)(mapcar(lambda(i)(r(sqrt(a(mapcar(lambda(x)(expt(nth i x)2))s)))))'(0 1 2)))
```
Does it [the correct way](https://www.youtube.com/watch?v=LKnqECcg6Gw), I guess. Untested. 
* `a` is just average
* `r` is this challenge's proper rounding, since Lisp `round` rounds to the nearest even integer
* `c` does the real work, taking in input in the format
 `'((R G B) (R G B) (R G B) (R G B) (R G B) (R G B) (R G B) (R G B))`, and returning a `'(R G B)` list containg the answer.
[Answer]
# [Nim](http://nim-lang.org), ~~134~~ ~~126~~ ~~115~~ ~~108~~ 78 bytes
```
import math,future
x=>lc[(lc[x[j][i]|(j<-0..7),int].sum+4)shr 3|(i<-0..2),int]
```
Defines an anonymous procedure, which requires the input passed in as a double-nested sequence and outputs as a 3-element array. The procedure can only be used as an argument to another procedure; to test, use the following wrapper:
```
import math,future
import strutils
proc test(x: seq[seq[int]] -> seq[int]) =
 echo x(#[ Insert your input here ]#)
test(x=>lc[(lc[x[j][i]|(j<-0..7),int].sum+4)shr 3|(i<-0..2),int])
```
A Nim sequence is an array with `@` in front, like `@[1, 2, 3]`. An input to this procedure could therefore be:
```
@[@[0,0,0],@[255,255,255],@[0,0,0],@[255,255,255],@[255,255,255],@[0,0,0],@[255,255,255],@[0,0,0]]
```
[Answer]
# [Forth (gforth)](http://www.complang.tuwien.ac.at/forth/gforth/Docs-html/), 65 bytes
```
: f 3. do 8. do 3 j - i * 2 + roll loop 4 8. do + loop 8 / loop ;
```
[Try it online!](https://tio.run/##tYzNCsMgEITveYo5NyQVraLN05QW@4Og2EAe366J1KSF3ors7Ozs@lkfx1t3tbmldISF6HHx0LMKPNDhjh04WkTvHJz3AYeyb5dRY7@YgQiBGNGP9LePeE6nfE1ulnPE0HDG8M8KDUN@XMp3fSe/t0uSSWvy56TW8eaEU5W5oqSC1FCyHAlRMeQZjK4QvWEYQyIR0gs "Forth (gforth) – Try It Online")
Takes input as stack arguments (r g b order)
### Explanation
For each of the 3 color channels:
* move all the numbers of that channel to the top of the stack
* add them together
* add 4 (to handle rounding)
* divide by 8
### Code Explanation
```
: f            \ start new word definition
  3. do        \ start a counted loop from 0 to 2
    8. do      \ start a counted loop from 0 to 7
      3 j -    \ get the offset of the channel
      i * 2 +  \ get the absolute position of the channel value
      roll     \ move the value to the top of the stack
    loop       \ end the inner loop
    4          \ add 4 to the top of the stack
    8. do      \ loop from 0 to 7
      +        \ add the top two stack numbers
    loop       \ end loop. (Result on top of stack with be sum of values for channel + 4)
    8 /        \ divide by 8
  loop         \ end outer loop
;              \ end word definition
```
[Answer]
# [Runic Enchantments](https://github.com/Draco18s/RunicEnchantments/tree/Console), 41 bytes
```
>iRi+ i+ i+ i+ i+ i+ i+8,'rA' q$;
>iU
>iU
```
[Try it online!](https://tio.run/##KyrNy0z@/98uMyhTWwEDWeioFzmqKxSqWHPZZYaC8P//BgqmZgqmFgpmpgoGCkYGBgrGxmDKQMEMzDZQsLSAygBJCwUjIyAF5VpaAglTAA "Runic Enchantments – Try It Online")
Utilizes 3 instruction pointers to parse the input in the correct order (as the input values are always in the order `RGB, RGB,...`) and as long as each of the three IPs don't merge, and don't advance to the next read `i`nput command too early (hence all the spaces), it works out and saves bytes over having to continuously [rotate the stack](https://tio.run/##KyrNy0z@/z/G2i4zM7M6U5sSVMQVZKGjXuSooq6g8v@/gYKpmYKphYKZqYKBgpGBgYKxMZgyUDADsw0ULC2gMkDSQsHICEhBuZaWQMIUAA) to keep the correct value on top in order to calculate the sums.
*Technically* this code contains an error in correctly rounding `x.5` values for some inputs, but this is due to the [default rounding method used by C#](https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=netframework-4.7.2#System_Math_Round_System_Double_), which is to round to the nearest event number, rather than upwards and is due to issues in floating point accuracy loss, and I was unaware of this issue prior to writing this answer and checking the test cases. This will be [fixed in a future build](https://github.com/Draco18s/RunicEnchantments/blob/master/Assets/draco18s/runic/runes/RuneMathFunc.cs#L39), along with a few other things such as [this unhandled exception](https://tio.run/##KyrNy0z@/9/OVsX6/38DBVMzBVMLBTNTBQMFIwMDBWNjMGWgYAZmGyhYWkBlgKSFgpERkIJyLS2BhCkA).
In the meantime, [this modification](https://tio.run/##KyrNy0z@/98uMyhTWwEDHdqqbaGjXuSorlCoYs1llxkKwv//GyiYmimYWiiYmSoYKBgZGCgYG4MpAwUzMNtAwdICKgMkLRSMjIAUlGtpCSRMAQ) makes the necessary adjustment.
[Answer]
# [Husk](https://github.com/barbuz/Husk), 8 bytes
```
mȯ÷8+4ΣT
```
[Try it online!](https://tio.run/##yygtzv7/P/fE@sPbLbRNzi0O@f//f3S0gY6pmY6pRaxOtJmpjoGOkYEBkGlsDGLogJhmBjpAHohlaQGXB9IWOkZGIKYRXKWlJVDeNDYWAA "Husk – Try It Online") Transposes the array and does the usual transformation.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, ~~8~~ 7 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
y_x÷8 r
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=eV949zggcg&input=W1swLDIwMCwyMDBdLFsyMDAsMCwyMDBdLFsyMDAsMjAwLDBdLFs2MCwyMDAsMF0sWzIwMCwwLDIwMF0sWzAsMjAwLDIyMF0sWzIsMjAwLDBdLFswLDAsMF1d)
```
y_x÷8 c     :Implicit input of 2D array
y           :Transpose
 _          :Map
  x         :  Reduce by addition
   ÷8       :  Divide by 8
      r     :  Round
```
]