Ad
  • Custom User Avatar

    Renaming's not a bad idea; makes the code portable. Not that this needs that in particular...

  • Custom User Avatar

    approved, one thing remained unclear to me from description, an "implicit conversion" is a "from -> to" from bindings (I would say this is an "explicit conversion"). Also "from -> to" and "to -> from" are two different kinds of conversions.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    I agree, thats brilliant

  • Custom User Avatar

    The problem is the for loop. For example when i=2 then with example initial_time = "12:45" then initial_time[i] is ":" which means initial_time[i][0:2] is also ":", which is an invalid input for int.

  • Custom User Avatar

    @lewissteward448 Please do not abuse the report system. I suggest you drop this topic.

  • Custom User Avatar

    I think you have the tests backwards. Your predicate is expected to behave like a generator, and produce single values at a time. The tests check for this by gathering all the values produced into a list. Your solution however produces one single list of all values at once, so the tests collect that into a list, creating a nested list, while the expected result is just a list.

    You need to rebuild your solution to produce individual values. Eg instead of this behaviour:

    foo([1, 2, 3]).
    

    You need behaviour like this:

    foo(1).
    foo(2).
    foo(3).
    
  • Custom User Avatar

    @TheChampionofValor This is a warning, do not abuse the report system any further, and stop threatening people.

  • Custom User Avatar

    @AliRain FYI while this translation is rejected, you can simply "Fork" it to keep the work you already did, and use that to implement random tests.

  • Custom User Avatar

    Thanks for the ping! I'm glad the kata is back, ill try solve it soon(ish)

  • Custom User Avatar
  • Custom User Avatar

    First, you should never claim something is faster without actually benchmarking it. Python has many hidden optimizations in built-in functions.

    Second, I guess my solution would be faster in most cases because any stops at the first True, and all stops at the first False, so it would only reach the end of the sequence if it consists of all equal elements. Your algorithm will reach the end in any case. Consider the situation [True, False, ...(10000 elements more)]. My algorithm will stop after checking the first two elements; yours will check all the sequence in any case.

    On the second thought, it would be faster in any case except, maybe, some very short sequences, because the first value of predicate would be either True or False, so one of the any or all functions is guaranteed to stop after checking it.

  • Custom User Avatar

    For your solution, I missed the iterator part in map. yes, the space complexity will be O(1) but then it is a slower iteration over sequence. a simple loop should be faster. Mind me I understand that they both are O(n) time complexity but simple loop should be a faster O(n) out of those two. let me know what you think.

  • Custom User Avatar
  • Loading more items...