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 feel this solution is better with O(n) time complexity. The with sum, min, and max function would mean O(3n).
very concise solution. however it takes 2 * len(arr).
My code works for both, so I see no harm in accounting for more cases.
the instructions explicitly state that it will only be 1 digit.
Fixed tests should include
0, 2, 29
to verify that the proper century is being solved for, because1900
is not a leap year, but2000
is.This was my initial thought, but I tried to account for ages more than just 1 digit.
how do you learn to write such elegant code?))
Alr, could've probably guessed that but being more sure is always nice. Thx :D
One-time math calculations are normally
O(1)
, although it depends on how they are implemented.For simple statements like this, it's quite pythonic to put it on one line. Even for more complicated statements with ifs and for loops and generators, it is still often pythonic to put it on one line.
YMMV in other languages.
I don't know about industrial programming, but here it is often done like this
Q: How conventional is it to have this on one line over multiple? Apologies if this is a silly question - still learning. :)
I see. Thank you.
This comment is hidden because it contains spoiler information about the solution
After ten years, I guess nobody is taking your suggestion. Closing.
Loading more items...