Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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
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
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.
Maybe not that faster but definitely less memory-expensive!
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
original solution with dictionnary !
I think len(l[0]) would be faster (O(1) instead of O(n))
Oh, I didn't know putting brackets would keep the sepators in list ! Thank you !
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]
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.
slower than necessery, and you kind of loose all the interest of the kata ?
shouldn't it also return 0 if n is anything elses than 9 ? (juste trying to understand it correctly)
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 :)
I don't follow PEP8 in codewars either.
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.
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...