# YOUR MISSION

An [octahedron](https://en.wikipedia.org/wiki/Octahedron) is an 8-sided polyhedron whose faces are triangles. 

Create a method that outputs a 3-dimensional array of an octahedron in which the height, width, and depth are equal to the provided integer `size`, which is equal to the length from one vertex to the opposite vertex on the octahedron.

## EXAMPLE

```python
create_octahedron(7)

[
    [[0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0]],
    
    [[0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0]],
     
    [[0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 1, 1, 1, 1, 1, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0]],
    
    [[0, 0, 0, 1, 0, 0, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 1, 1, 1, 1, 1, 0],
     [1, 1, 1, 1, 1, 1, 1],
     [0, 1, 1, 1, 1, 1, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 0, 0, 1, 0, 0, 0]],
     
    [[0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 1, 1, 1, 1, 1, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0]],
     
    [[0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 1, 1, 1, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0]],
     
    [[0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 1, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0],
     [0, 0, 0, 0, 0, 0, 0]]
]
```

where each 1 represents a cubic unit that the octahedron takes up and where 0 is a cubic unit of empty space.

# NOTES

 - The method should return an empty array/list if either 
  - The input size is even (because then it wouldn't be an octahedron. It'd be an irregular polyhedron with 26 sides)
  - if the input size is 0 or less
  - if input size is 1 (that's called a cube).
 - If there's any problems with this kata (*COUGH* [my last Kata](https://www.codewars.com/kata/5bf76f953efcee37e2000061) *COUGH*), I'll try to get them fixed in the evenings before 10pm.

Difficulty: introductory

Starter code:

def create_octahedron(size):
	

Solutions:
def create_octahedron(size):
    if size <= 1 or size % 2 == 0:
        return []
    m = size // 2
    return [[[int(abs(x - m) + abs(y - m) + abs(z - m) <= m)
        for z in range(size)]
        for y in range(size)]
        for x in range(size)]

def face(size, m, n):
    return [
        [abs(r-m) + abs(c-m) <= n for c in range(size)]
        for r in range(size)
    ]

def create_octahedron(size):
    if size == 1 or size % 2 == 0:
        return []
    m = size // 2
    return [face(size, m, min(i, size-1-i)) for i in range(size)]

def f(n):
    r = []
    for i in range(1,n//2+2):
        x = [0]*((n//2+1)-i) + [1]*i
        r.append(x[:-1] + x[::-1])
    return r

def create_octahedron(n):
    ones = f(n)
    zeros = [0]*n
    r = []
    for i in range(1,n//2+2):
        m = ones[:i][:-1] + ones[:i][::-1]
        x = n//2+1 - i
        r.append([zeros]*x + m + [zeros]*x)
    return r[:-1] + r[::-1] if n>1 and n%2 else []

def create_octahedron(size):
    if size<3 or size%2==0:
        return []
    result = []
    center = size//2
    for plane in range(size):
        inner = [[0 if abs(center-i)+abs(center-j)+abs(center-plane)>center else 1 for i in range(size)] for j in range(size)]
        result.append(inner)
    return result

def create_octahedron(size):
    if size%2 == 0 or size <= 1: return []
    r1, r2, r3 = [], [], []
    
    for i in range(size//2+1):
        for j in range(size):
            for k in range(size):
#                 if j-i <= k <= j+i and size-j-1-i <= k <= size-j-1+i and j-(size-1-i) <= k <= j+size-1-i and (size-1)-j-((size-1)-i) <= k <= (size-1)-j+((size-1)-i):
            # brain and server exhausting, time limit, but funny
            # halving cube and mirroring at the end doas the trick
            
                if j-i <= k <= j+i and size-j-1-i <= k <= size-j-1+i:
                    r3.append(1)
                else: r3.append(0)                
            r2.append(r3)
            r3 = []
        r1.append(r2)
        r2 = []
        
    for i in range(size//2-1, -1, -1):
        r1.append(r1[i])

    return r1

def create_octahedron(size):
    if not (size > 1 and size&1): return []
    res = [[[0]*size for _ in range(size)] for _ in range(size)]
    s = size>>1
    for i in range(-s, s+1):
        x = abs(i)
        for j in range(x-s, s-x+1):
            y = abs(j)
            for k in range(x+y-s, s-x-y+1):
                res[s+i][s+j][s+k] = 1
    return res

def create_octahedron(n):
    if n%2==0 or n<=1: return []
    m, y = n//2+1, []
    for j in range(m):
        x = [list(map(int,'0'*(m-i-1+(m-j-1))+'1'*(2*(j+i-m+1)+1)+'0'*(m-i-1+(m-j-1)))) if i>=m-j-1 else list(map(int,'0'*n)) for i in range(m)]
        y += [x+x[:-1][::-1]]
    return y+y[:-1][::-1]