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

    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

    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

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

  • Custom 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! ;))