Minimum moves taken to move coin of each cell to any one cell of Matrix | Function to find the minimum number of moves taken to move the element of each cell to any one cell of the square matrix of odd length ; Initializing count to 0 ; Number of layers that are around the centre element ; Iterating over ranger of layers ; Increase the value of count by 8 * k * k ; Driver code
def calculateMoves ( n ) : NEW_LINE INDENT count = 0 NEW_LINE layers = n // 2 NEW_LINE for k in range ( 1 , layers + 1 ) : NEW_LINE INDENT count += 8 * k * k NEW_LINE DEDENT return count NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 5 NEW_LINE print ( calculateMoves ( N ) ) NEW_LINE DEDENT