Ad
  • Custom User Avatar

    Try the TDD approach:

    Test.assertEquals(beeramid(1, 1), 1);
    Test.assertEquals(beeramid(2, 1), 1);
    Test.assertEquals(beeramid(4, 1), 1);
    Test.assertEquals(beeramid(5, 1), 2);
    // ...
    
  • Custom User Avatar

    Added sample tests

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    No worries. I just look to see if all the code in that box is greyed out. If so, there's no actual test cases. You can still put in your own, though; that's kind of the intended use.

  • Custom User Avatar

    Ah, I see now. I guess I'm just used to Katas having built-in test cases. Thanks.

  • Custom User Avatar

    There aren't any tests I've put into the "your test cases" section, so nothing will run there unless you put your own tests in there. Maybe there was just an issue with your tests?

  • Custom User Avatar

    Very weird, the "run tests" button didn't work. But the "submit" button works fine.

  • Custom User Avatar

    Seems to run fine and pass everything for me. What do you mean by the "original test"?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    It seems your code modifies the inputed array (array) :

      //...
      var arr = array; // <-- for now `arr` IS `array`  ...
      //...
      arr.reverse();   // <-- ...so, here `array` is reversed too
    

    Your code works fine on repl.it because you test only 1 rotation (rotate(data, 2)), add another rotation before yours . . . :

    var data = [1, 2, 3, 4, 5];
    rotate(data, 1) // <-- 1st rotation test (which should be right)
    rotate(data, 2) // <-- tadaaa ; [ 2, 1, 5, 4, 3 ] instead of [ 4, 5, 1, 2, 3 ] !
    

    Hope it helps! ;))

  • Custom User Avatar

    I'm getting this error:

    Expected: [4,5,1,2,3], instead got: [2,1,5,4,3]

    I have no idea why, everything works correctly from what I can tell. This is my code: https://repl.it/CYOf

  • Custom User Avatar

    When running my tests for JS I got

    Solution
    should test for something
    Expected: expected, instead got: actual

    But it worked fine when I submitted it.