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.
Nah,
push()
becomes redundant whenclass
changed. Also, instructions ask to try to usepush()
inbuild_one_two_three()
, so directions not really followed.Then I stand corrected, thank you.
I still don't like that it puts the condition after the if_true code
Ternary operator in Python is less "functional", not less "powerfull".
Yes, you can't do such stuff with ternary, but you can call functions using ternary as well.
I should have explained myself better:
It doesn't use the classic
condition ? if_true : if_false
format but theA = X if true else Y
which I find less explicit and much less powerful as it's only useful for value assignment, you can't for instance docondition ? x += 1 : callFoo()
What?
@monobrawl
Is
value if value >= last else -value
a "false" ternary?I personally considered it but opted out as I find it less readable, too bad python doesn't have a true ternary operator i.e:
total += (value >= last ? value : -value)
...wait I thought it said 2 weeks not 2 years, sorry :)
It creates a new head for the given linked list or creates a new list itself, what's wrong? Seems to be correct and neat for me.
Since
min_max
isn't documented, you expect the argumentlst
to hold the following property:After all,
min_max
extracts information fromlst
, so it's not necessary to modify the list. Changing the list would surprise the user.That being said, your solution runs in O(n log n) compared to the optimal O(n). If you don't know the O-notation: if the list has
n
elements, your solution needs abouts * (n * log n)
operations to get the minimum (wheres
is some constant), whereas an optimal solution only usess' * n
operations (wheres'
is another constant). If you're interested in O-notation, search for "Big O notation" or "Landau notation".And why is it dangerous? Do you think I could lost some part of imput or is it a question of Best Practices?
I'm not really experienced programmer so thank you in advance for your answer.