Ad
  • Custom User Avatar

    I just got it to work. I think the issue is just that there are a bunch of ways of trying to compute this that seem fine if the numbers are reasonable, but are not efficient enough for very large numbers (in the millions). I found several working solutions before arriving at an efficient enough one. Perhaps it would help to have a test in the default array of initial tests that includes some larger numbers. For others working on this: there are 160 tests in the final battery. If you completed 10 in the 12000ms, you are not close to being efficient enough. (I never knew while working on it. Wished I had.) Thanks for the kata, g964!

  • Custom User Avatar

    @nikolaninkov I am having this timing issue as well. Did you end up figuring something out?

  • Custom User Avatar

    @dinglemouse @kazk I did not mean to make an "issue." I felt sure I had marked "suggest an optional improvement." Also, this is my first time commenting on any coding website, so my apologies if I was unclear with what I said. There is not a general rule in place that says "If someone uses a value in an example, then you should use that same value in your code," so regardless of whether the example uses the first two items in the array, somewhere it ought to say which two items are to be swapped in the actual instructions for the kata. Since there is no reason to assume that the first two items are to be swapped, and since there is no additional difficulty in writing code that swaps any two items, my suggestion is to pass the array locations of the items to be swapped via arguments to a function and have the would-be-coder make a function that can swap any two items from any array like so: "function swap(arr,first,second){etc...}". I really am sorry if that seems like a bad idea. For some reason I cannot reply directly to your comments and I don't see a way to eliminate the "issue" I never meant to post. Also -- I voted "somewhat," which I assumed would be counted as a "satisfied" vote since "somewhat satisfied" is a sub-genre of satisfied. So my intention here has NOT been to harm this kata. But I'm not intimately acquainted with how the website calculates satisfaction. Is there really no space between only "somewhat" and "very?" Can a person not be simply "satisfied"?

  • Custom User Avatar

    It might make sense to say something about how many values to expect the input array to have and which values the function is meant to swap. It seems like it might be cool to have a function that allowed users to call it with the index of each of the values they want switched as arguments.

  • Custom User Avatar

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