Ad
  • Custom User Avatar

    I have exactly the same. My basis tests are passing but then when i try the random tests it gives me that too.. Don't know what to do now..

  • Custom User Avatar

    Oh wow, thanks so much! Can't believe I missed that haha

  • Custom User Avatar

    I have never used ruby before, so I apologize for any strange terminology I use.

    Your issue seems to stem from this line: return s[(n-(n/2)-1),(n-(n/2))]

    I believe what you THINK it is doing is incorrect. You seem to be trying to use it as a range. For example, if I wanted to get position 3 and 4, I would say s[3,4]. That, however, is wrong. (I believe that you would just use s[3...4] for that).

    What that array call actually does is that it gets the first number and then the next n numbers (s[StartingIndex,NumberOfIndexesToGrab]). So it actually looks like this: s[3,4] = position 3, 4, 5, and 6. That is why you are getting 3 letters on the word Middle instead of 2.

    To Fix this, you have 2 options. If you want to do it the way you intended, then you need to use the ... operator to get a range of numbers: return s[(n-(n/2)-1)...(n-(n/2))+1]

    or to get it the other way, you just need to change the second part to a 2 so that you only grab 2 entries: return s[(n-(n/2)-1),2]

    Both of those should give you the answer you are looking for. If you have any questions, or if I didn't explain something well enough, let me know.

  • Custom User Avatar

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