Ad
  • Custom User Avatar

    This is clever, but not so intuitive in my opinion.
    But I'm just getting started with Python and programming in general, so I might change my opinion further down the rabbit hole!

  • Custom User Avatar

    Hello,
    from what I understand, if (number % a > 0 or number % b > 0) it will return False because then that is some value.
    number % a here is equals to number % a > 0.
    so, the program returns True if number % a and number % b DO NOT have any values( because then they are of value 0 )

  • Default User Avatar

    thx! :) (Note: do not forget the spoiler flag, when you throw bits of code in the comments: they are visible from anyone in their dashboard)

  • Custom User Avatar

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

  • Default User Avatar

    What list lengths were tested? If it's function calls that are expensive, it's still a constant factor, it may be able to significantly affect times for only really small lists.

  • Custom User Avatar

    @KenKamau: I understand. Don't get me wrong, this wasn't meant as criticism, just as a fun little observation in case other users wondered if and how the two top voted solutions differed.

    @Unnammed: My comment was based on the following timeit results (first fct is sum(arr1+arr2):

    array_plus_array1 took 5.588323692000131 secs to complete 10000000 repetitions
    array_plus_array2 took 6.547926787000051 secs to complete 10000000 repetitions
    

    So as you can see the performance difference is very small, but it's there. My best guess is that's caused by the additional function call which to my knowledge can be pretty expensive in Python.

  • Default User Avatar

    Proof? I don't believe adding numbers can be slower than adding the same numbers and allocating memory for a whole list and copying everything.

  • Default User Avatar

    It's 8 Kyu. I don't think about performance in such Katas.

  • Custom User Avatar

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