Given a matrix represented as a list of string, such as
```
###.....
..###...
....###.
.....###
.....###
....###.
..###...
###.....
```
write a function
```if:javascript
`rotateClockwise(matrix)`
```
```if:ruby,python
`rotate_clockwise(matrix)`
```
that return its 90° clockwise rotation, for our example:

```
#......#
#......#
##....##
.#....#.
.##..##.
..####..
..####..
...##...
```
>  /!\  You must return a **rotated copy** of `matrix`! (`matrix` must be the same before and after calling your function)  
> Note that the matrix isn't necessarily a square, though it's always a rectangle!  
> Please also note that the equality `m == rotateClockwise(rotateClockwise(rotateClockwise(rotateClockwise(m))));` (360° clockwise rotation), is not always true because `rotateClockwise([''])` => `[]` and `rotateClockwise(['','',''])` => `[]` (empty lines information is lost)

Source: codewars | Difficulty: EASY
Tags: Matrices

Fundamentals

Starter code: def rotate_clockwise(matrix):
	

Solutions:
def rotate_clockwise(m):
	return [''.join(l[::-1]) for l in zip(*m)]


def rotate_clockwise(matrix):
	matrix = [[c for c in line] for line in matrix]
	return [''.join(line) for line in zip(*matrix[::-1])]


rotate_clockwise = lambda m: list(map(''.join, zip(*m[::-1])))


def rotate_clockwise(matrix):
	return [''.join(l)[::-1] for l in zip(*matrix)]


def rotate_clockwise(matrix):
	return list((''.join(row) for row in zip(*matrix[::-1])))


def rotate_clockwise(matrix):
	return list(map(''.join, zip(*matrix[::-1])))


def rotate_clockwise(matrix):
	return [''.join(i) for i in zip(*reversed(matrix))]


def rotate_clockwise(matrix):
	if not len(matrix):
		return []
	res = []
	for x in range(len(matrix[0])):
		temp = []
		for y in range(len(matrix) - 1, -1, -1):
			temp.append(matrix[y][x])
		res.append(''.join(temp))
	return res


def rotate_clockwise(matrix):
	return [''.join(row) for row in zip(*reversed(matrix))]


def rotate_clockwise(mx):
	if not mx or not mx[0]:
		return []
	(l0, lm, m, r) = (len(mx[0]), len(mx), [], '')
	while l0:
		lm -= 1
		r += mx[lm][l0 - 1]
		if not lm:
			m.insert(0, r)
			lm = len(mx)
			l0 -= 1
			r = ''
	return m