Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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 :/
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
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.
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?