Ad
  • Custom User Avatar

    Print the input yourself.

  • Custom User Avatar

    LOL - amusingly I wrote: "I have two suggestions" -- then presented 3 items.

    Reminds me of a joke:

    There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors

  • Default User Avatar

    Yeah but the test did not mention which string was tested, so no debugging is possible
    (at least in python)

  • Custom User Avatar

    You've probably taken an approach that decrements the number until the new number has the same digits (i.e., next smaller) or some terminal case (e.g., 0, fewer-digits, etc.) This approach will timeout on this kata.

    To get yourself unstuck, I have two suggestions:

    1. Try some carefully chosen inputs that you know will be difficult for your algorithm. In the above case, try: 900,000,000,001 - the next smaller number with the same digits is 190,000,000,000. Why? In respect to the above algorithm, having to spin through all those decrement and digit tests needs to happen about 710 billion times. If 1 iteration required just 1 ns, the 710 billion times through the loop would require 710 seconds for just this one simple input (there will be hundreds or thousands like it in the official tests. )
    2. If your code works pretty well with hand crafted inputs, try adding code to your solution to print every 10th (or every 100th) and time those. Or some similar variation of adding timing and logging the ones that take a long time.
    3. This isn't one that I resort to often, but you can go parallel. When you're close to making the mark, sometimes this will allow your algorithm to finish in time. In general though, it's better to look for algorithmic improvements.
  • Custom User Avatar

    Your solution returned a wrong result.

  • Custom User Avatar

    Because True is not a number.

  • Custom User Avatar
  • Custom User Avatar

    Try reading the examples and problem description one more time

  • Custom User Avatar

    There are no floating point numbers in Python tests, and the input is a number, it can't be mutated. The first number is the result your function is returning, not the input value.

    A should equal B # A: your function output, B: the expected value
    

    29 friends each checking 2 pills should cover 58 pill types

    Why only 2 pills, you have read DestyNova's post and its answers, you can see there an example where each one of 3 people takes 4 pills and they cover 8 jars.

  • Custom User Avatar

    Are you mutating the input? (i.e. don't mutate/modify the input)