13
Caleb Kelley
Last seen 4 years ago
Member for 9 years, 2 months, 8 days
Difficulty Normal
You should use super() so that the value isn't tethered to the base class. For this application, there won't be any problem. But subsequent changes to the base class could result in problems later on in bit projects.
More
I always like using default dict myself. Didn't think to use it on this one though.
More
I know this is a recursive solution, but could you walk me through your rational behind this solution? I would really appreciate learning from this solutions.
More
Another approach to this problem would be to use the regular expression engine. You should check it out. I used the re.findall function: re.findall([a-zA-Z]+[\']?[a-zA-Z]?, text). The '+' operator is the greedy lookpup operator, so that first pattern is looking for as many upper/lowercase characters
More
This is pretty awesome. Deleting the first instance, then searching for the character,then remembering to add one to the index since you removed a character before finding the second occurrence. Then using True/False as an index selector. Pretty cool. +1
More
Instead of using find, you could have use text.index(begin) and text.index(end) to find the index, you could also use try/except. In except you could use the default of start = 0, and end = len(text).
More
This is nice and short, and it has fault tolerance. But, if I were to ask you to find the nth occurrence of the sub-string in text, multiple nested function calls could get pretty ugly, and maybe inefficient.
More
I think that I understand the regular expression matching pattern. But I don't understand how you have used a lambda. From my understanding, the re.sub takes a matching pattern, a function accepts a match object(here you created a lambda to swap the values of '.' and ',' on match group zero), t is t
More
I like this. I did the same thing but I didn't use deque.Clear and easy to follow.
More
This is pretty good, it shows you have a working algorithm. But consider, instead, if you were to shift all of the values in alpha, by delta. Then you could get an inline relationship to alpha and shifted_alpha. From there one loop would give you the answer. Good job.
More
Can you please break this down for me. What is the rational in using these two lambda functions in the way you have. I'm trying to learn a little more.
More
The range function doesn't require you to specify the starting point to zero, it is zero by default (python is 0-indexed based. Also, you should check out list comprehensions. As simple as this is coded, you could have maybe made it more readable with a list comp.
More