Ad
  • Custom User Avatar

    I really struggled at first because of the lack of sample tests. I ended up just guessing based on comments that you could new Node() and passed that into loop_size in a test. Then console.logged it to see what I was actually dealing with. That gave me a look at the Node object. From there, the light bulbs started to go on, and I created this really ugly test. My first CW test! :-P

    describe("Ugly Test", function(){
      it("LinkedList of 7 nodes connected at 3rd should have a loop link of 5", function(){
        var first = new Node()
        var second = new Node()
        first.setNext(second);    
        var third = new Node()
        second.setNext(third); 
        var fourth = new Node();
        third.setNext(fourth);
        var fifth = new Node();
        fourth.setNext(fifth);
        var sixth = new Node();
        fifth.setNext(sixth);
        var seventh = new Node();
        sixth.setNext(seventh);
        seventh.setNext(third);
        
        var size = loop_size(first);
        Test.assertEquals(size, 5, "The size should be 5");
      });
    });
    
  • Custom User Avatar

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