Imagine there's a big cube consisting of n^3 small cubes. Calculate, how many small cubes are not visible from outside.

For example, if we have a cube which has 4 cubes in a row, then the function should return 8, because there are 8 cubes inside our cube (2 cubes in each dimension)

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def not_visible_cubes(n):
	

Solutions:
def not_visible_cubes(n):
	return max(n - 2, 0) ** 3


def not_visible_cubes(n):
	if n > 1:
		return (n - 2) ** 3
	else:
		return 0


def not_visible_cubes(n):
	if 0 <= n <= 2:
		return 0
	return (n - 2) ** 3


import math

def not_visible_cubes(n):
	if n < 2:
		return 0
	else:
		return (n - 2) * (n - 2) * (n - 2)


def not_visible_cubes(n):
	return pow(n - 2, 3) if n > 2 else 0


def not_visible_cubes(n):
	return n > 2 and (n - 2) ** 3


def not_visible_cubes(n):
	if n == 0 or n == 1 or n == 2:
		return 0
	totalCubes = n * n * n
	cubesPerSide = n * n
	outsideCubes = cubesPerSide + 2 * (cubesPerSide - n) + cubesPerSide - 2 * n + 2 * (cubesPerSide - (n + 2 * (n - 1) + n - 2))
	return totalCubes - outsideCubes