Ad
  • Custom User Avatar

    Ranked 6 now. Too high for that also.

  • Custom User Avatar

    Definitely overranked, but it can't be changed anymore.

  • Default User Avatar

    Hi,

    if nums.count(0) > 1: is my mistake. In my solution, I reuse the zeros.

    filter(None, iterable) is an idiomatic use described in the Python documentation (see here).

    @FArekkusu:(foo(x) for x in arr) is a generator expression and it returns a generator too.

    Regards,

    suic

  • Custom User Avatar

    My code looks like the way it does because it's easier and shorter to write.

    Were it not a proper input, I guess that it should be guarded by an assert

    What?..

    that's the boilerplate that so many Pythonist just hate

    It's always a good practice to use try-except block if you know what you're doing -_-

  • Custom User Avatar

    It could easily be worse than O(4n) because you're searching for 0's index inside your list comprehension. Twice.

    Your speech about Python's functional language features are wrong. Python is not functional because lambda's are restricted to one-line functions. Moreover, map lets you apply a pre-defined function to the array elements using a very concise syntax - map(foo, arr) instead of (foo(x) for x in arr), and it also returns a generator instead of the whole list which is a big advantage when you can't waste memory. The same applies to filter.

    And again you don't know when it's better to use filter. For simple situations list comprehensions are a lot better choice.

    And regarding being pythonic - the truly pythonic code is [x for x in arr if x] (or alternatively filter(lambda x: x, arr)).

  • Custom User Avatar

    You yourself think that way.

    Don't assume stuff out of nowhere. I haven't said anywhere which option I prefer. In fact, I prefer neither one as an empty array would be an incorrect input.

    Some solutions posted and acepted as right are actually wrong because of this (ie. Wangsihe, Hickock)

    You should post a link to the solution. No sane person will spend their time scrolling through thousands of code snippets to see that there're wrong solutions which do not work properly.

  • Custom User Avatar

    The third test case makes no sense. Technically, the result is "YES" as he doesn't get into a situation where he can't give the correct change. On the other hand, the answer is "NO" because there're no customers to sell tickets to...