Ad
  • Default User Avatar

    it's my first time doing python, and this is quite good for beginners.
    Great kata!!🧟‍♂️

  • Custom User Avatar

    Isn't this pretty much a duplicate of this?

  • Custom User Avatar

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

  • Default User Avatar

    nice! really simple compared to other answers, but I do have a question that I would love if someone could clarify them!

    what does the [-2::-1] do exactly?

  • Custom User Avatar

    The term you are looking for I think, is "aliasing"

  • Custom User Avatar

    nothing is shadowed, here, the builtin is just assigned to another name in the current scope, that's all.

  • Custom User Avatar

    I think shadowing a built-in generally refers to asigning a built-in to something else, e.g. print = lambda x:x+1

  • Custom User Avatar

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

  • Default User Avatar

    Why does this work?
    Isn't that just the import syntax or does it somehow return something as well?

  • Custom User Avatar

    Why I do level 8 Kata. :D

  • Custom User Avatar

    One possible answer is given in the docs https://docs.codewars.com/authoring/tutorials/create-first-kata

    Basically, there is no easy answer as to how to create a good task. Rather, there is a vast list of "don't's":

    • don't be repetetive, as many ideas have already been implemented: just solve more to see that;
    • don't make user perform additional dull actions to complete it. For example, in your last kata, it was about clearing additional spaces;
    • don't make description a mind flow; come up with a description, which is clear and understandable. Imagine, as if your grandma should understand it. User should be able to understand the task without looking at the sample tests (except puzzle katas, maybe);
    • don't just use floats: if you design the task about numbers, always pick up appropriate number type from the math point of view. Choose between int (bigint), fractions, decimal, and only as the last resort floats.

    As to how come up with original ideas, it's a difficult question. There are different types of katas, and some users come up with ideas more often than others. Consider, for example, math olympics tasks. Such tasks may appear as sudden intermediate step in some math work. Many ideas come from life. Again, as you solve more katas and get more experience, you will know more and you will start notice more things, which in turn will stimulate your imagination further.

  • Default User Avatar

    I would like to ask how to create a good kata?

  • Default User Avatar

    If I try the random tests, here is one input I just got:

    * 5 / 49 - 21 / 52 with variable = 99

    If you solve this only using // you get answer 49504 - this is what your solution expects.

    If you solve this using / you get answer 51542.4 which is the valid mathematical solution - it is fully reversible - so you can work backwards and you will get the original input 99:

    (((51542.4/52) - 21 )/ 49) * 5 = 99

    Meanwhile, if I feed back the expected answer 49504 to the equation - because of the repeated use of //, I will not get back the input value:

    (((49504//52) - 21 )// 49) * 5 = 95 <--- NOT 99

  • Default User Avatar

    I kind of don't understand what you're talking about!

  • Default User Avatar

    It's really not clear from the description that you are expecting all divisions (in the "reverse process") to be carried out using floordiv or //.

    Especially as, in your own test cases, you use / to refer to the "divisions" that are presumed to have taken place to obtain the result in the "forward process".

    Also - mini-issue, your random test formula have trailing whitespace (you can remove this with .rstrip() to avoid users having to work it out themselves if they process their strings without using regex)

  • Loading more items...