Ad
  • Default User Avatar

    Here you sort ALL the 50 millions element and after you had to compare the digit (not linear for sur).

    But all you have to do is to look element by element and find the first one who is not asc (linear).

    Sorry for my english

  • Default User Avatar

    Probably it's the most fastet solution. Can you explain please why do you think that this solution is slow?

    test on a list of len 50 millions

    your decision took time: 2.390636682510376

    supposedly slow decision took time: 1661070264.348622

    your decision longer on 1.7343978881835938

  • Default User Avatar

    weird how you got dislikes. i even had 7kyu challenges that are harder than this one. 6kyu - 7kyu sounds more accurate.
    note even sure why some people struggle with this one because its really straight forward (no mathematical trick, no algorithmic trick, no performance issues).
    maybe some people dont know how to play sudokus and have a hard time understanding this problem.

  • Default User Avatar

    Maybe not that faster but definitely less memory-expensive!

  • Default User Avatar

    Yeah you're right, I didn't think about that at first and I submitted a solution that uses len instead of count later on

  • Default User Avatar

    original solution with dictionnary !
    I think len(l[0]) would be faster (O(1) instead of O(n))

  • Default User Avatar

    Oh, I didn't know putting brackets would keep the sepators in list ! Thank you !

  • Default User Avatar

    This solution seems much better to be than the "best practice/clever" above ones. Lets vote for it ahah :)
    Question however : you chose to say it was false if arr[i]>=arr[i+1], I chose to accept it, it seems both pass the tests ?
    The instructions didn't say what to do if arr[i]==arr[i+1]

  • Default User Avatar

    this one is more efficient than the one using sorted !
    you could also compare arr[i] and arr[i+1] to avoid the use of a third variable.

  • Default User Avatar

    slower than necessery, and you kind of loose all the interest of the kata ?

  • Default User Avatar

    shouldn't it also return 0 if n is anything elses than 9 ? (juste trying to understand it correctly)

  • Default User Avatar

    Yes don't worry I don't take it wrong :) I don't know standard at all !
    I put the comment mostly for myself ahah :) to separate things (while I saw you put spaces).

    Same about the return : I know this is useless, but I sometimes find it clearer. I didn't know it was against standard : thank you for teaching me that.

    (Just to be sure : I didn't made the fork about refactoring/because of your presentation, my idea was "ah, he made the same than me (and you gave me the idea of generator, while I did a function) but mine is faster because of this check things, lets see if I can adapt his code to do so too.)
    My fork was not criticizing your presentation, sorry if there where a misunderstanding here :)

  • Default User Avatar

    I don't follow PEP8 in codewars either.

  • Default User Avatar

    You have not followed standard PEP8 layout. e.g. move==end should be move == end, adding an elif after a retun and having a statement on same line as an else.

    Comments shoud have a space after the #

    Like this

    Commenting the obvious is not helpful. e.g # Inititializations... abolve the place where code is initialised is redundant. Adds to cognitive load.

    I have made these comments with good intentions.

  • Default User Avatar

    good idea to stock previous node in a dictionnary instead of copying all path each time as I did !
    It seems a little faster (not sure it is because of that, but I think so ?) with about 650ms against 700-800ms.

  • Loading more items...