Ad
  • Custom User Avatar

    Write some test cases for the user to test against.

  • Custom User Avatar

    Be careful not to modify anything you don't intend to.

  • Custom User Avatar

    Thanks for sharing! That article shed some light on Ruby programming practices.

  • Custom User Avatar

    As someone who is learning ruby, why do some solutions omit a return in the function? I see doing so works, but coming from other OOP langages, this seems very...wrong. I've seen this in multiple ruby kata so far. Can someone explain?

  • Custom User Avatar

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

  • Custom User Avatar

    I seem to be having trouble with the Test Case. Here's my output with some console.log calls added to find the length of the list passed in:

    Testing list with 10 elements
    n: 2
    xs.length: 10
    10
    Test Passed: Value == [9,10]
    n: 0
    xs.length: 10
    10
    Test Passed: Value == []
    n: 2
    xs.length: 10
    10
    Test Passed: Value == [-1,0]
    Testing list with more elements
    (List of 5559 elements)
    n: 26
    xs.length: 8326
    8326
    Test Passed: Value == [5535,5537,5539,5541,5543,5545,5547,5549,5551,5553,5555,5557,5559,5561,5563,5565,5567,5569,5571,5573,5575,5577,5579,5581,5583,5585]
    n: 16
    xs.length: 8300
    8300
    16 largest of 5559 elements - Expected: [5555,5557,5559,5561,5563,5565,5567,5569,5571,5573,5575,5577,5579,5581,5583,5585], instead got: [5525,5525,5526,5526,5527,5527,5528,5528,5529,5529,5530,5530,5531,5531,5532,5532]
    

    I'm confused as to why xs.length is different than the number of elements to sort. I didn't include it here, but I've also used console.log to see the value of xs.length and didn't see the Expected values. Is this a bug?