5 kyu

Rotate a square matrix in place

358 of 408fungairino
Description
Loading description...
Matrix
Algorithms
  • Please sign in or sign up to leave a comment.
  • saudiGuy Avatar

    python new test framework + random tests are required. updated in this fork

  • akar-0 Avatar

    COBOL translation, with random tests (author inactive).

  • akar-0 Avatar

    No random tests in Python and Ruby.

  • RNOH Avatar

    This kata should invalidate my solution.

  • william01424 Avatar

    Hey there, I just completed this one on Leetcode and thought I would grab some codewars points for it as well if it was on here.

    I was wondering if someone could shed some light on my solution for me - while it does pass all the tests, am I not technically going against the rules of the problem by making another 2d-array? I know I got around it by doing "matrix[:] = res", but doesn't that kinda beat the point of the problem? All my test cases were accepted on both Leetcode and here, but I wanted some clarification on whether this type of thing was allowed for questions that state "Do not return anything, modify matrix in-place instead."

    Cheers!

  • ozichukwu Avatar

    This comment has been hidden.

  • clydiscope Avatar

    Really cool problem! Refreshed my matrix operations and learned a neat ruby trick all in one fell swoop! Thanks fungairino@!

  • zebulan Avatar

    This comment has been hidden.

  • SimplGy Avatar

    I'd like to build a JS version of this kata. Is there a way to do that and keep these two katas together as a translation bundle?

  • zellerede Avatar

    This comment has been hidden.

  • NicholasSeward Avatar

    You might want to indicate which test cases are testing the "in-place" requirement. Nice Kata!

  • nickie Avatar

    It should be clearer how much extra memory is allowed.

  • BeniaminK Avatar

    Rotating in place isn't checked. The output should be done "in place", while even without change of input value (matrix value), the output is marked as correct, which is simply wrong. This is major issue.

  • user9935269 Avatar

    For the 4-dimensional test case, I believe [[ 1, 2, 3, 4], [ 5, 6, 7, 8], [ 9,10,11,12], [13,14,15,16]] would be clearer than [[ 1, 2, 3, 4], [ 4, 5, 6, 7], [ 7, 8, 9,10], [11,12,13,14]]

    Otherwise, a nice honors system challenge!

  • SagePtr Avatar

    In place means that I can't create additional matrices, but can use few scalar variables?