
Hello, checkiomates🐱👤!
This edition delves into advanced Python concepts to enhance your coding acumen. Explore the power of higher-order functions, learn how to navigate the tricky pitfalls of Boolean logic, and uncover an innovative take on binary search using bidirectional generators. Wrap up your learning with a hands-on mission to implement the Luhn algorithm for credit card validation.
💡TIP
We allow users to assign hotkeys to "Run Code", "Check Solution" and stop code. You may see current combinations on buttons and change them in editor menu. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁 MISSION
Luhn Algorithm: Credit Card Checker by freeman_lex -
Use Luhn algorithm to validate credit card numbers. Every credit card number is given as a string and has a correct form of four four-digit blocks, separated by single whitespace.
checker("4137 8947 1175 5904") == True checker("5468 1234 5678 9123") == False checker("4539 1488 0343 6467") == True
📖 ARTICLES
The Hierarchy of Controls (or how to stop devs from dropping prod) -
The other day a mechanical engineer introduced me to the Hierarchy of Controls (HoC), an important concept in workplace safety. Can we use the Hierarchy of Controls in software engineering? Software environments are different than physical environments, but maybe there are some ideas worth extracting. Let’s go through the exercise of applying HoC to an example problem: a production outage I caused as junior developer.
Often when using a Boolean in an API you are making the API harder to understand. This post explains why most of the time you should use enums instead.
Binary search as a bidirectional generator -
This article proposes an implementation of an ergonomic binary search algorithm implemented as a bidirectional generator.
👩💻CODE SHOT
How do you think, what the following code does?
def checkio(result): diags = ([row[i], row[~i]] for i, row in enumerate(result)) for lines in result, zip(*result), zip(*diags): for a, b, c in lines: if a == b == c in 'OX': return a else: return 'D'
🙌 Thanks for your attention! Hope to meet you at CheckiO, as well as at our Instagram and Twitter! We are really interested in your thoughts! Please, leave a comment below! ⤵