In this kata your mission is to rotate matrix counter - clockwise N-times.

So, you will have 2 inputs:

    1)matrix

    2)a number, how many times to turn it

And an output is turned matrix.  
Example:

    matrix = [[1, 2, 3, 4],
              [5, 6, 7, 8],
              [9, 10, 11, 12],
              [13, 14, 15, 16]]
          
    times_to_turn = 1

It should return this:

    [[4, 8, 12, 16],
     [3, 7, 11, 15],
     [2, 6, 10, 14],
     [1, 5, 9, 13]])

Note: all matrixes will be square. Also random tests will have big numbers in input (times to turn)

Happy coding!

Source: codewars | Difficulty: EASY
Tags: Matrices

Starter code: def rotate_against_clockwise(matrix, times):
	

Solutions:
def ccw(matrix):
	return [list(row) for row in zip(*map(reversed, matrix))]

def rotate_against_clockwise(matrix, times):
	for __ in range(times % 4):
		matrix = ccw(matrix)
	return matrix


import numpy as np

def rotate_against_clockwise(matrix, times):
	return np.rot90(matrix, times).tolist()


def rotate_against_clockwise(m, t):
	return rotate_against_clockwise([list(r) for r in zip(*m)][::-1], t % 4 - 1) if t else m


def rotate_against_clockwise(matrix, times):
	if times == 0:
		return matrix
	else:
		matrix = [list(row) for row in zip(*matrix)][::-1]
		return rotate_against_clockwise(matrix, times % 4 - 1)


rotate_against_clockwise = lambda a, n: rotate_against_clockwise(list(zip(*a))[::-1], n - 1) if n % 4 else list(map(list, a))


def rotate_against_clockwise(matrix, times):
	return list(map(list, zip(*matrix)))[::-1] if times % 4 == 1 else rotate_against_clockwise(list(map(list, zip(*matrix)))[::-1], times - 1)


def rotate_against_clockwise(m, n):
	for _ in range(n % 4):
		m = [[r[i] for r in m] for i in range(len(m))][::-1]
	return m


def rotate_against_clockwise(matrix, times):
	for i in range(3 - (times + 3) % 4):
		matrix = list(map(list, zip(*matrix[::-1])))
	return matrix