Ad
  • Custom User Avatar

    I suggest making lists given the description comment about 10,000,000 length lists with both valid pairs in various locations, and ones without any valid pairs, just to ensure your algorithm can even parse through a list with that many elements without timing out first.

  • Custom User Avatar

    Fixed

  • Custom User Avatar

    These are the sample tests:

    Test.expect(nbrOfLaps(5, 3)[0] == 3, 'x = 5, y = 3 The number of laps for Bob is wrong. Expected 3, got ' + nbrOfLaps(5, 3)[0] + '!')
    Test.expect(nbrOfLaps(5, 3)[1] == 5, 'x = 5, y = 3 The number of laps for Charles is wrong. Expected 5, got ' + nbrOfLaps(5, 3)[1] + '!')
    Test.expect(nbrOfLaps(4, 6)[0] == 3, 'x = 4, y = 6 The number of laps for Charles is wrong. Expected 3, got ' + nbrOfLaps(4, 6)[0] + '!')
    Test.expect(nbrOfLaps(4, 6)[1] == 2, 'x = 4, y = 6 The number of laps for Charles is wrong. Expected 2, got ' + nbrOfLaps(4, 6)[1] + '!')
    Test.expect(nbrOfLaps(5, 5)[0] == 1, 'x = 5, y = 5 The number of laps for Bob is wrong. Expected 1, got ' + nbrOfLaps(5, 5)[0] + '!')
    Test.expect(nbrOfLaps(5, 5)[1] == 1, 'x = 5, y = 5 The number of laps for Charles is wrong. Expected 1, got ' + nbrOfLaps(5, 5)[1] + '!')
    

    The third test is mislabeled. Instead of saying The number of laps for Charles is wrong. it should be The number of laps for Bob is wrong. since it's testing the first element of the result of nbrOfLaps, which is Bob. I don't know if it makes a difference but I'm writing JavaScript.

  • Custom User Avatar

    How do you write a timeout test? I'd like to test against it. If I can write a few timeout tests then I can be confident in my code.