6 kyu

Matrix Rotation

287 of 485cyril-lemaire

Description:

Given a matrix represented as a list of string, such as

###.....
..###...
....###.
.....###
.....###
....###.
..###...
###.....

write a function

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)

Matrix
Fundamentals

Stats:

CreatedJun 12, 2017
PublishedJun 12, 2017
Warriors Trained1188
Total Skips48
Total Code Submissions1973
Total Times Completed485
JavaScript Completions156
Ruby Completions42
Python Completions287
Scala Completions24
Total Stars43
% of votes with a positive feedback rating94% of 161
Total "Very Satisfied" Votes144
Total "Somewhat Satisfied" Votes16
Total "Not Satisfied" Votes1
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • cyril-lemaire Avatar
  • docgunthrop Avatar
  • xavierguihot Avatar
  • saudiGuy Avatar
Ad