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.
What kind of idiotic comment is this? RegExp is a powerful and extensively tested tool. This solution maps the problem to the text domain so we can use regex to solve it in a robust way. Be my guest to reimplement a few of the regex functionalities in a bug-ridden way to try and solve the problem.
The tests only use a precision of 1e-6 when comparing the results
This comment is hidden because it contains spoiler information about the solution
@Oblix Have you even tried running count_smileys([">:D"]) before posting your comment?
This comment is hidden because it contains spoiler information about the solution
Does this work if you drink
n
standard drinks wheren
> 10?Be careful with the join(). My original solution used a space to join the smileys because of cases like
[":","-)"]
.Indeed, in this case there is none. But since backslashes are so common in RegEx, instead of checking everytime whether a regex has backslashes or not (and hence whether it is better to use a raw string or not), we just acquire the habit of always using a raw string. That was what it was done here.
This comment is hidden because it contains spoiler information about the solution
I'm used to the C89 version, where the loop variables had to be declared at the beginning of the function.
I'd say readability is more important, unless you know a given piece of code is going to be a hotspot, in which case optimizing it for runtime would be more important (with proper documentation to describe the optimization if it is non-obvious).
What I like in Python is that, once you are at easy with it, and that doesn't take too long, readability correlates many times with code succintness. Paraphrasing Eistein, "make it as short as possible, but not shorter"...
You are indeed correct. Thanks for pointing this out!
Thanks for your comment. I do like your version with a dictionary better. A slight change I'd make, though, would be
This change notwithstanding, your solution is beautiful, better than mine.
Note (disgusting pun intended), however, that the variable
notes
, according to the kata description, has simple strings instead of a list with one string, and for this reason what you suggest in a comment (NOTES = notes*2
) wouldn't work (I haven't used notes so I don't know if the test fixture actually implements it that way).I think we both should train this kata again and publish this solution for the benefit of others. What do you say?
Thanks. Not that this is my solution, but I agree with you...
Beautiful code. I must say you are one of the few I go looking for the solution after I finish a kata to compare with mine. I learned one thing or two specially with respect to
re
. My solution to this kata in particular was a mess (I may someday go back and refactor it). For that reason I was the most impressed by yours.See you around!
Loading more items...