Ad
  • Custom User Avatar

    "foobar00" turns into "foobar01" because the end result after the string was incremented was 2, which did not take up both digits. If it was "foobar09", then it would turn into "foobar10", because the result now takes up both zeros which were in the input. In the case of "foobar099", 99 turns into 100, meaning it now takes up 3 digits. In "foobar099", there are 3 numbers at the end, so you would not include the extra 0 after incrementation.

  • Custom User Avatar

    Thank You. That was a really concise explanation.

  • Custom User Avatar

    Okay, thanks. I understood

  • Custom User Avatar

    Yes, and no.

    Because of some specifics (which are partially explained in docs), usually kata have two kinds of tests which are run when you hit the ATTEMPT button: so-called "fixed tests", and so-called "random tests". Fixed tests are the same every time. Random tests are generated separately for every test run. Ideally, when a solution has some bug, there should be always at least one fixed test case which fails every time on wvery run of the solution, accompanied by at least a few failing random tests, which can be different every time. This is an ideal situation. But it happens quite often that coverage of the fixed test is either neglected by authors, or difficult to ensure for some types of problems. In such case, it can happen that your faulty solution will pass all fixed tests, but can fail some randomly generated tests. As a result, you will see no pattern between failed test runs.

    This is one possible explanation of the behavior you observe. Other reasons are also possible, but we cannot say anything for sure without seeing your code.

  • Custom User Avatar

    No no, I didn't mean that. I mean if I run the same code more than once the test cases that failed should be same but each time I run the code there is a change of failed test cases.

  • Custom User Avatar

    In a class, there are three types of methods: instance methods, class methods, and static methods. Instance methods are defined with a mandatory parameter self, alongside any other required parameters. For class methods, we use the @classmethod decorator before the method and include a mandatory parameter named cls, along with other parameters. Static methods, on the other hand, don't require a decorator and function like normal Python functions without needing a mandatory parameter. When written within a class, they behave as static methods by default, but you can add clarity by using the @staticmethod decorator. Remember it's common practice to use decorators and highly recommended.

  • Custom User Avatar

    Why did you use @staticmethod on top of all the functions? (I am a newbie so pardon my questions)

  • Custom User Avatar
  • Custom User Avatar

    Yes, this is the whole meaning of "random tests".

  • Custom User Avatar

    weird! same code ran twice but different test cases failed!!!!!!!

  • Custom User Avatar

    No chromosome is written like this, X comes first then Y.

  • Custom User Avatar

    Not good practice as it should be simple and readable

  • Custom User Avatar

    this not good good practice when it's not rot13 case

  • Custom User Avatar

    Double is used for slicing not indexing

  • Custom User Avatar

    In your problem I don't think you need a constructor(you can pass) for your given tasks.

  • Loading more items...