Hello, checkiomates🐱👤!
This week, we boost performance by learning to speed up Python using concurrency, navigate complex text processing with a comprehensive guide to RegEx, PRegEx, and Pyparsing, and explore the history and guaranteed ordering of Python's OrderedDict. Our mission challenges you to find the minimum cost path to connect a map's northern and southern edges by strategically digging canals through land cells.
💡TIP
At every mission page, under the editor window, there is a terminal window. If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁 MISSION
Digging a Canal by bryukh -
The robots are trying to colonize a new island. There are many rivers on this island and it would be good idea for them to use ships designed for water, rather than their spaceships. Some of the territories do not have a river for transportation from one edge of a field to another. The robots can dig a canal and convert the land to water if need be. We must explore a field map and count the minimum number of cells necessary for a canal that would allow the robots to sail from northern edge of the map to southern edge. The map is in a 2D array, where 0 is water, 1 is land. Cells are connected by their edges.
checkio([[1, 1, 1, 1, 0, 1, 1],
[1, 1, 1, 1, 0, 0, 1],
[1, 1, 1, 1, 1, 0, 1],
[1, 1, 0, 1, 1, 0, 1],
[1, 1, 0, 1, 1, 1, 1],
[1, 0, 0, 1, 1, 1, 1],
[1, 0, 1, 1, 1, 1, 1]]) == 2
checkio([[0, 0, 0, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 0, 1, 0, 1, 1],
[1, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0]]) == 3
📖 ARTICLES
Speed Up Python With Concurrency -
Concurrency is the act of having your computer do multiple things at the same time. If you’ve heard a lot of talk about asyncio being added to Python but are curious how it compares to other concurrency methods or are wondering what concurrency is and how it might speed up your program, you’ve come to the right place.
Choose the Right Text Pattern Tool: Regex, Pregex, or Pyparsing -
Parsing messy support tickets? This post walks through real-world examples of Python techniques for extracting structured data from unstructured text. It compares the re module for classic pattern matching, pregex for cleaner and more readable regex construction, and pyparsing for more complex structures.
How Does Python’s OrderedDict Maintain Order? -
This article takes a closer look at the inner workings of OrderedDict and explains what it takes to implement an ordered dictionary in Python.
👩💻CODE SHOT
What do you think the following code does?
from operator import itemgetter checkio = itemgetter(0, 2, ~1)
🙌 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! ⤵
