24
Last seen 1 month ago
Member for 6 years, 2 months, 3 days
Difficulty Normal
Interesting solution, just using error handling. Perhaps you could replace (hehe) line 8 with "return bool(re.fullmatch(p, filename))" to get rid of the double negation?
More
In contrast to popular opinion (well, as it seems to me...) I prefer your nicely commented and readable approach to a convoluted one-liner. Good work!
More
Ah, every time I see a solution with yield, I think: Great, I have to use that, too... but I never seem to make it ;) . I like your solution!
More
Clear solution, great!
The for-loop with the else and if seems a bit convoluted, though. I wonder, if you could save one indentation there with an elif, but it is still reasonably readable, so hardly worth the effort.
More
Very nice solution, I had no idea of that use for 'from' with yield. I also really like your commentary at the end, which really helps to understand it. I had to scratch my head a bit to understand the last return statement, with the 'next', but I think now I got it ;).
More
Very explicit solution, easy to understand! I have one question though: You don't initialize your subclasses and just give them the variables 'food_name' and 'drink_name' (without 'self'). Then in the parentclass you use 'self.food_name' etc. Why does this work, why don't you have to __init__ it? Th
More
Good use of the all()-build-in. You can leave out the square brackets for the list-comprehension though. all() does not need them!
More
Wow, thanks for making me aware of LRU cache, cool solution. That seems to fit nicely here. One question though: You seem to rely heavily on strings. Wouldn't it be faster to use sets (or dicts) for this?
More
Very elegant, I think, how you use the dict for this. I just used str.replace() twice, but your solution seems to be more versatile!
More
Very interesting to use a class for this, I have to try that for these tasks, too, because I use them not too often, sadly ;) . Can you explain, what you did in the Treasures __init__ with the vars(self) ? I don't quite get it. Thanks!
More
And here I am deploying a simple if/else conditional... ;) . Good work!
More
That is a working solution, but perhaps you could lookup the string methods replace and capitalize. Python makes it easy for you :) .
More
Nice work, that is really interesting. I have to look into dataclasses. One (possibly dumb) question: Doesn't the army class need an __init__? I mean, there are Army instances that have to be initialized? Thanks!
More
Very clear, good job. You could save you some work/lines, when you write a parent class for the fighter types, I think.
More
Straightforward and clear solution. Question to the 'else'-branch: Couldn't you make it an 'elif' to get rid of the nested 'if'? Should make it clearer!
More
That is a really neat solution, as far as I can tell. I like your use of namedtuple and getattr here, that's really inspiring. I hope to remember this ;) . One question though: I didn't reproduce it completely and it seems to work, but does the code really make sure that there is only the one correc
More
Clear solution, good work! For this task a if-conditional is reasonable, but for greater grids it would be difficult ;) . Another thing: Shorter lines, i.e. a timely linebreak would make for far more readable code.
More
Very nice! I really have to get into datetime a bit more. I didn't know that you could do that nice trick with the leading zero there!
More
Very interesting! Great explanation and nice use of the dictionary. Makes me wonder, did you actually compare the running time to a more standard solution with a couple regex searches? Everybody, it seems, tries to do these things with perhaps not so optimal one-liners, when such a "ugly" (you wrote
More
Good solution with datetime. In cases like this I try to solve it without datetime and just manipulate the string, because I always have a hard time getting into the whole datetime terminology ;) . In the long run your approach pays off, I think, so good work!
More