Code Challenge 11 - Generators for Fun and Profit - Review

PyBites, Sat 25 March 2017, Challenges

code review, codechallenges, Counter, glob, learning, regex, yield

It's end of the week again so we review the code challenge of this week: Generators for Fun and Profit. It's never late to join, just fork us and start coding.

Our solution + learning

This was a pretty easy one, yet showing a powerful way to start thinking about generators as pipelines that can be plugged into each other.

Our solution is here. A couple of notes:

Community branch

We got our first solution PR which we merged onto our community branch. This is a nice way to get credit and help our community learn more.

The solution was pretty similar to ours. One nice addition was to sort manually on both values and keys, most_common only sorts by values. Also the regex part was slightly different stripping off import with re.sub. It is nice to see different solutions to the same problem, you learn more.


Next week we do another game, so we expect some more complexity and variety in solutions. Stay tuned ...

Do you like these challenges?

We hope you are enjoying this. If we can do anything better or you have ideas please open a new issue or reach out to us. See you next week ...

PyBites Python Tips

Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.

Get our Python Tips Book

"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H

"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B

"This is now my favourite first Python go-to reference." - Anthony L

"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S

Get the book