Ad
  • Default User Avatar

    I can explain. Unfortunately, quality checking on Codewars is poor, people can rate katas and raise issues, but it's up to the author's ability to understand what's wrong and their good will (which they may lack even if they clearly understand and know how to correct, having been politely informed – happened to me, so I don't want to do it anymore until the Codewars team come up with some improvement to the process (I do have some ideas) (but unlikely, as they have serious issues reported on GitHub and unsolved for almost 10 years, like the one that you can try to see your friend's or your own solution which definitely exists (as shown by Codewars elsewhere) but it's not there)). One of the most common problems is that tests test for too little (and often also too much) and allow much easier incorrect solutions to pass. (One of my ideas: allow others to write tests and earn honor points thereby, with some verification, e.g. by some supermajority of votes, perhaps weighted by voters' honor (a ninja could use proposed but yet unverified tests as an option, not required to pass the kata, but potentially useful).)

  • Default User Avatar

    This isn't guaranteed to work. For sort to return a permutation of the elements to sort it's required (per https://tc39.es/ecma262/multipage/indexed-collections.html#consistent-comparator) for the passed function to be a consistent comparator. One of the conditions is that 0 must be returned when the same argument is passed in both position. With yours it's -1 when a and b are 0.

  • Default User Avatar
  • Default User Avatar

    added to Java, JS, C#

  • Default User Avatar

    what language ? added to JS

  • Default User Avatar

    I know the problem. The definition of Caesar cipher you quoted is the general one. As far as I remember (the kata has many years... first translation is 7 y.o) I avoided negative shift though I am rather sure that in my solutions I wrote "my" modulo to prevent that kind of problem in some languages. For a lot of reasons (lack of time amongst others) I don't see interest to change something. Sorry:-) Maybe one day you author your own kata (some kind of variation on Caesar cipher with negative shift:-) and see the pain to try to maintain them as best as possible!

  • Default User Avatar

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

  • Default User Avatar

    Yes, it works now, thanks!

    By the way, the test suite (including basic and random) seems to always give strings starting with a letter to encode. From what I see in the solutions, some people assume it (as did I up to the moment I realized the desciption didn't guarantee it, so it's required to handle the other case too), some don't. I imagine you wouldn't like (or even be able to, depending on how Codewars works; I don't know, I haven't created any kata yet) to invalidate those solutions, so maybe add this condition to the description.

  • Default User Avatar

    Could you try again? There was such a dubious case but I removed it.

  • Default User Avatar

    The random tests in Scala give data like this to decode: List( _ (cpofnp * (, cpaple 20 1000, )) LctesxpetnP, inpaetzy tyepr, pc zgpcqwzh ). This is impossible – you can't get it from encode, the first 2 characters are always letters.

    Also, adding a sample test in which the data to encode doesn't start with a letter (but contains at least one, which is one of the many implicit conditions the kata description entails) would be prudent IMO.

  • Default User Avatar

    Imagine me saying in my best attempt at a Vulcan voice: "It's adequate" 🖖

  • Default User Avatar

    Nevertheless I modified the dubious case.
    Thanks for your posts!

  • Custom User Avatar

    The - now deleted - bug was caused by me. This was due to a minor inconsistency (according to me :-) , maybe not you )

    The info says you only encode A-Z and a-z, the rest is left as is. The way my implementation does this is taking the leading space and adding the shift, so with the leading space and say shift 5 my first two characters would be ' %'. The bug was due to me not encoding characters outside the A-Z/a-z range in my little routine. The way the test in C is constructed is you're decoding your own coded message. As long as it follows my own mechanism, it'll pass. Maybe this is how you intended it, and is how everyone encodes it, I don't know.

  • Default User Avatar

    I will look at it. Until now nobody have told something about that.

  • Custom User Avatar

    I'll mark it as resolved.

  • Loading more items...