I have a 3×4 array that I want to rotate left once, so that it becomes a 4×3. Imagine a box of values, and just rotate that box left. Here’s the function I wrote:
This code should be working, as it passes my handwritten test (when I run it on paper), but when I try to run it through the grader that my teacher wrote, it fails the test. What’s wrong with this code?
Matt Ball is absolutely correct, writing your own tests is the way to go. Many different tests.
One problem I see is that you have confusion between length and width in
source.length-jexpression. I.e.,jis the second index of array and may be> source.length. Run it on1x3matrix and you’ll get some very funny error.