Ad
  • Custom User Avatar

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

  • Custom User Avatar

    Why replicate Python's range in any language at all? Especially given its behavior is nonsensical.
    I've seen plenty of katas about implementing built-in features (without using the existing ones of course) so your question is not as rethorical as you seem to believe.
    Have a nice day.

  • Custom User Avatar

    Sorry, but while the Python range function has weird semantics, it does not in any way justify a signature like function(optional_argument, required_argument, optional_argument)...

    It is very strange to want a function to have optional arguments that do not come last.

    Say I call range(a, b)... Is the first optional argument omitted? Or the third one? How would you tell?

    Just because the Python range function is messed up and makes very little sense and cannot be improved because retro-compatibility is vital... does not give this kata any value. Especially with other languages in the mix.

    Say I really go out on a limb and make language semantics allowing ANY argument to be optional....
    Then I could write this:
    my_wonderful_function = (optional_arg1 = default_arg1, required_arg2, optional_arg3 = default_arg3) {...}
    But then what if someone calls my_wonderful_function(0, 2)? Is it arg1 = 0 and arg2 = 2, or arg2 = 0 and arg3 = 2?

    Optional parameters which go before required parameters make NO sense. Even less so in a language like JavaScript which treats undefined, null, 0, '', and [] as similar unless you ask for a super strict comparison.

    TL;DNR: if the point was to reproduce the very weird behavior of Python's range function, maybe it should have been restricted to Python (or forgotten entirely and never made into a kata).

    Optional arguments always come last.

  • Custom User Avatar

    Who in their right mind would decide to make the first argument optional but not the next one?

    If start is optional and not stop, then the proper signature should be range(stop, start = 0, step = 1).

    Also the behavior for step = 0 or start > stop make zero sense to me.

  • Custom User Avatar

    Isn't it? I mean, sure, the author didn't do their homework and plan for malicious compliance in their tests... but the instructions say it's a 2D-array, not a 8x8 chess board.

  • Custom User Avatar

    What if the size of the board could change?

  • Custom User Avatar

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

  • Custom User Avatar

    Seems I don't have permission to delete the kata... Oh well, I'll leave it as an unpublished draft and forget about this mess.

  • Custom User Avatar

    @Kacarott Thank you very much for the suggestion and the link. I am really not sure right now I'll ever feel like trying to make a kata again... but if I do, I'll go to the discord server first, as you suggested.

  • Custom User Avatar

    @Kacarott It is entirely possible that I am the one who does not understand how sieves work. It is true that your story involves mostly indices, so it could well be a proper sieve. I don't know. And it's your idea and story, not mine. I would feel terrible plagiarizing it.

  • Custom User Avatar

    @akar-0 Well... I'm gonna delete it soon. No point bothering people with a stupid duplicate.

  • Custom User Avatar

    @Kacarott
    Your story sounds cool... though it's really got nothing to do with the sieve of Eratosthenes anymore. I would love to train on your kata, though.

    @akar-0
    I see. So unless I find some way to force people to use an actual sieve (without spoon-feeding them the solution), I might as well give up?

    Every other kata I train on feels like 'déjà-vu' to me... but fine.

    Hope y'all have a better day than mine T_T

  • Custom User Avatar

    Another idea could be to ask for a sieve with explicit marks... I mean, something like:
    sieve(10) === [[], [], [], [], [2], [], [2, 3], [], [2], [3], [2, 5]]

    Would you guys think it's a better way to test that the sieve algorithm was actually used? Or would that just be a list of prime factors and then I'd just be duplicating a different category of katas?

  • Custom User Avatar

    @akar-0
    I respectfully disagree: I believe there is a difference between a sieve and a list of primes. Though it is possible to build one from the other... Working on strings and working on arrays would not be considered the same thing, right? Yet they are closer in essence than sieves and lists of primes.

    As for asking people to implement a class... It could work. I'm wondering how to do it in such a way that I don't end up implementing most of the algorithm already, though.

  • Custom User Avatar

    @Kacarott
    Sounds interesting, but... it's not a sieve. The positions of the strings will not help determine if they should be marked or not... and you'll have to check for the "marked" strings anyway. Example:
    ['zog', 'zoga', 'oga']
    You can't mark the element at index 1 and then move on the way you would in a sieve.

    EDIT: perhaps if what is checked is that the string starts with a previous one, as that would mean a marked string can be ignored. Positions would still not matter though.

  • Loading more items...