Ad
  • Custom User Avatar

    Strange, I took your solution and removed that line and it passes all the tests perfectly. I guess there were no problems after all!

  • Custom User Avatar

    If it's the Ruby version, I've fixed it.

  • Custom User Avatar

    Fixed

  • Custom User Avatar

    C# expected and actual arguments were flipped. I fixed it.

  • Custom User Avatar

    I used this and it worked.

    long result=hammings[n-1];
    return result;

    I don't know why, but I'm just happy it passed. Oh well :/

  • Custom User Avatar

    Okay, I'll have a look later.

  • Custom User Avatar

    It's also inconsistent. This time I changed nothing but the debug outputs, and the first sample test passed. Here is the debug code and the output.

    Console.WriteLine("List count="+hammings.Count);
    Console.WriteLine("n-1="+(n-1));
    Console.WriteLine("Going to return: hammings["+(n-1)+"]="+hammings[n-1]);
    return hammings[n-1];

    List count=7
    n-1=1
    Going to return: hammings[1]=2
    System.ArgumentOutOfRangeException : Index must be within the bounds of the List.
    Parameter name: index

  • Custom User Avatar

    I mean, hammings[n-1] is fine and contains the correct value when used inside Console.WriteLine, but it raises an exception when I'm trying to return it. I believe this is a problem with the website. I have checked for n=0 beforehand. For the first sample test, the hammings list contains four elements, and n-1==0. It still raises the exception.

  • Custom User Avatar

    Not an issue. If you have problems with your code, you should raise it as a question.

    Two things:

    • what if n=0?
    • Note that you're getting an ArgumentOutOfRangeException.You should look at both the list and the index instead of still trying to get item from that index ;-)
  • Custom User Avatar

    The last two lines of my code are

    Console.WriteLine(hammings[n-1]);
    return hammings[n-1];

    The console gave the correct answer, but when I returned the value it raises the following error:

    System.ArgumentOutOfRangeException : Index must be within the bounds of the List.
    Parameter name: index

    I am 100% certain the value of n can't change between the two lines... anyone know why this bug exists?