15
Last seen 9 years ago
Member for 9 years, 11 months, 9 days
Difficulty Normal
Excellent code, and excellent explanation. Thank you for taking the time to share.
More
I hadn't thought of putting an int in the list instead of the word itself, thank you for the education :-)
More
I misunderstood the task. line #3 is Unnecessary and also makes my function break on inputs such as
count_words("AB CAB",{'abc'})
More
Hello,
If you wanted, lines 15 and 16 could be rewritten as just
return False
which I find to be more clear. Up to you though :-).
It is an interesting idea to keep a running count of how many more brackets have been opened than closed as well as a stack, but I think it is not neede
More
Very cool solution. If you wanted to be a little more concise, you don't need to pass the current total (curr) down the recursive chain and then back up, you can get away with passing the running total back up only.
For instance,
def partial(data):
if data:
return dat
More
I hadn't realized you could alter a list with .extend() while iterating through it with a for loop, that's good to know. Thank you.
More
If you want to be a little more concise, you can unpack the date arguments directly into the datetime function with a '*'.
datetime.datetime(*d1) == datetime.datetime(d1[0],d1[1],d1[2])
More
Just out of curiosity, is there any reason to use while loops instead of for loops?
More
Is there an advantage to using a try/except block instead of checking the array length?
More
Is there any particular reason you squished everything into one return statement?
More
This is completely functional, but just a note, dictionaries can become fairly inefficient as their size grows.
More
I'm not a fan of the 7-deep nested blocks, and re-iterating over every character so many times.
More