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.
I disagree. An array of the same numbers is sorted, but it is ambiguous what direction it is sorted.
Thanks for the reply! You reminded me that time complexity does not depend on the number of traversals (i.e. O(n) vs. O(3n)). Seems that for a while I've been torturing myself in writing algorithmns XD
because it's simpler to write/debug (overall) and that won't change a thing about the actual speed (time complexity is the same). Actually, if you time your code, you'll see that this one is way faster (I didn't check, but that's a safe bet) because of python's interpreter (using builtins function is faster, most of the time).
so, less code, more readable, less occasions to do a typo, less to maintain, meaningfull way to handle the problem (="accumulate meaningful data, then use them"). So, definitely the way to go. ;)
cheers
I think there is a need to add description specification for the case where the input is an array of the same numbers.
I personally take that as a "no" even though it fits both ascending and descending sorting definitions.
Your program will return "yes, ascending" for an array of same numbers while I think that should be a "no".
Of course the description should've made it clear.
The program fails the test when n = 0.
Why do people traverse a list twice when traversing it once is enough?
This is my first program in python - hoping to solve my confusion..
This is the greatest solution I have ever seen.