Joined December 2012
·
Posted to
Index of minimum element of a list
over 1 year
ago
Sure. It means that, by default, Python considers that tuple (a,b) is less than or equal than (a',b') if and only if a is less than a' or if a equals a' and b is less than or equal than b'.
In symbols: (a,b) <= (a',b') if and only if a < a' or ( a == a' and b <= b' ).
I'll link the term 'lexicographical order' to the Wikipedia article in my protip. Thanks!
Posted to
A Better Fibonacci
over 1 year
ago
Hi Jared,
nice to show this in Coderwall.
BTW, you can do better: from some point on, the formula is still simpler since (1-phi)^n/sqrt(5) becomes strictly less than 0.5 in absolute value, and from that point on you can compute F_n as the nearest integer to phi^n/sqrt(5), i.e., using the round function instead of floor. This is true because the original formula yields an integer.
Achievements
149 Karma
28,062 Total ProTip Views
Walrus
The walrus is no stranger to variety. Use at least 4 different languages throughout all your repos
Mongoose
Have at least one original repo where Ruby is the dominant language
Charity
Fork and commit to someone's open source project in need
It just works! Thanks!
BTW, do you know such a neat one-liner which also adds syntax highlighting?