Ad
  • Default User Avatar

    With the other one no memoization is needed. But it's fine I will remove the kata as promised, I was just interested to see how others would solve this.

    edit: Looking at monadius's solution I now realize the program is not reset inbetween test cases, all this time I assumed this was the case. As it stands now it is in practice a duplicate. I have unpublished the kata

  • Custom User Avatar

    So it's a duplicate after all.

  • Custom User Avatar

    This solution shows this kata is no different than the other, if memoisation is used

  • Custom User Avatar

    Problem with the Collatx problem is that its difficulty cannot be easily related to inputs. It is difficult to know whether given input is difficult or not, and it is difficult to test only difficult inputs. That's why I think that building a performance challenge for Collatz problem can be hard.

    If this is really meant to be a performance version, it should take proper care of testing performance-sensitive inputs, and account for techniques like memoization etc.

  • Custom User Avatar
  • Custom User Avatar

    My solution takes 8 seconds to calculate every case up to 5e6; by memoising those results a bit better it would take negligible time for every case after the first.

  • Default User Avatar

    I checked, your solution takes 8 seconds to calculate 1 case of 5e6, it will time out on the 70 test cases in this kata. I would argue the point of these two kata's is different, but we can disagree on that. I don't think a translation should be significantly harder than the original, that would also undermine the spirit of were_cat's kata. There are a lot of examples of kata that have both an easy and hard version on here, mostly being different in their input range.

    Having said that, if someone ends up solving this kata with a similar trivial approach, I will agree and withdraw this kata immediately

  • Custom User Avatar

    The JS version ( the only one I can see ) tests 1e6, and has no random tests, so submitting again won't make that test go away. ( Not having random tests is a problem in itself, but that's been raised already. )

    I checked; my solution to that kata will handle 5e6, and it's nothing special. I remain unconvinced. Seeing how the other kata doesn't even specify input range, you could just translate and test with the numbers you want to test with.

  • Default User Avatar

    Bedankt, added input range to description

  • Default User Avatar

    Thank you for your reply. I checked the kata you mention before publishing mine. While they too claim performance, the input range of the random tests are only up to 2x10^5 for just a couple of cases. As advised by the author these "large" cases can even be avoided by submitting repeatedly to get a test set without these numbers.

    In this kata however up to 5x10^6 is checked consistently. The bruteforce algorithms that work for that kata and the mentioned optimizations in the description will not suffice.

    I have found it rare to see input ranges mentioned in kata explanations, but I will add them now to the description for added clarity. I must say I do like kata's that are clear on this better.

  • Custom User Avatar

    Input range should be specified in the description.

  • Custom User Avatar

    This should very probably be a translation on https://www.codewars.com/kata/53a9ee602f150d5d6b000307/ instead of a separate kata.

    Neither this nor the other one specify exact input ranges though ( which is its own Issue .. ), but both make performance claims.