• Recall Tools For String Interpolation In Yet Another Sliding Window Mission

Hello, checkiomates🐱‍👤!

Today's digest is dedicated to strings. We offer you to dive deeply into different instruments for string interpolation and find the shortest window in strings to have all needed characters.

💡TIP

You may click on any mission tag and see all missions, where this tag is present! If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!

🏁MISSION

Minimum Window Substring by freeman_lex -

Given a string line and a pattern, write a function to find the minimum window substring of the line that contains at least all the characters of the pattern (may contain other characters also). The order of the characters in the line/pattern doesn't matter, but the letter case does. Your function should return a tuple of starting and ending indexes of line which form the needed window (right border is excluded). If there is no such substring in line to match pattern, return (-1, -1).

window("ADOBECODEBANC", "ABC") == (9, 13)
window("ab", "a") == (0, 1)
window("ab", "A") == (-1, -1)

📖ARTICLE

String Interpolation in Python -

String interpolation allows you to create strings by inserting objects into specific places in a target string template. Python has several tools for string interpolation, including f-strings, the str.format() method, and the modulo operator (%). Python’s string module also provides the Template class, which you can use for string interpolation. The author covers them in the article.

👩‍💻CODE SHOT

Tricky code for simple operation. I like it the moment I see it. How do you think, what the following code does?

from math import sumprod

def ?????(levels: list[int]) -> int:
    return abs(sumprod(sorted(levels), (1, -1, -1, 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! ⤵

Welcome to CheckiO - games for coders where you can improve your codings skills.

The main idea behind these games is to give you the opportunity to learn by exchanging experience with the rest of the community. Every day we are trying to find interesting solutions for you to help you become a better coder.

Join the Game