Draft

Rotate Square Matrix Clockwise, In Place.

Description:

Given a square matrix, rotate it 90 degrees to the right.

For example, given:

[
  ['a','b'],
  ['c','d']
]

return:

[
  ['c','a'],
  ['d','b']
]

And given:

[
  ['a','b','c','d'],
  ['e','f','g','h'],
  ['i','j','k','l'],
  ['m','n','o','p'],
]

return:

[
  ['m','i','d','a'],
  ['n','j','f','b'],
  ['o','k','g','c'],
  ['p','l','h','d'],
]

This is an honor-system Kata. There's only so much I can do to enforce that you use an in-place algorithm. If you cheat and move more than one value at a time you'll feel like a dirty, dirty cheater, so hopefully that's enough.

You can call stringify to get a loggable representation of your progress if you'd like. eg: console.log(stringify(sq)).

If you're lucky enough to be discoving a matrix rotation for the first time, do yourself a favor and don't google it. It can be figured out from scratch and it's incredibly rewarding, though time-consuming, to do so.

Also, I'll warn you, this is an off-by-one minefield.

Good luck, have fun!

Fundamentals
Matrix
Algorithms

More By Author:

Check out these other kata created by SimplGy

Stats:

CreatedOct 7, 2016
Warriors Trained80
Total Skips0
Total Code Submissions108
Total Times Completed26
JavaScript Completions26
Total Stars3
% of votes with a positive feedback rating75% of 12
Total "Very Satisfied" Votes8
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes2
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • SimplGy Avatar
Ad