-
Do a Lot: Capture, Count and Light Up While Learning Advanced Python Mastery!
Hello, checkiomates🐱👤!
Did you know, that if you find an iteresting solution, you may add it to your bookmarks by clicking the flag near solution title. You can find all your bookmarked solutions by clicking your nickame and than "Bookmarks". If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!
🏁 MISSIONS:
Today we have prepared varies missions for you! You need to light up a garland, count squares having points and capture enemy's checkers! Hurry up to show everyone your skills! 🐍
Garland by freeman_lex - You are given a sequence lights, where each integer is a distinct light with its brightness. This value determines how many adjacent positions to both left and right the illumination from that light reaches, in addition to illuminating the position of that light itself. (A light whose brightness is zero will therefore illuminate only itself, but doesn’t have anything to shine on its neighbors).
Your task is to turn on as few individual lights as possible so that every position of the entire row is illuminated by at least one light. Since the smallest working subset of lights is not necessarily unique, your function should only return the number of lights needed to illuminate the entire row.
illuminate_all([0, 0]) == 2 illuminate_all([2, 3, 3, 2]) == 1 illuminate_all([1, 0, 1, 0]) == 2
Count Squares by freeman_lex - Given a sequence of points (coordinates x, y as nonnegative integers), your function should count how many squares exist so that all four corners are members of points. Note that these squares are not required to be axis-aligned so that their sides would have to be either horizontal and vertical. For example, the points (0, 3), (3, 0), (6, 3), (3, 6) define a square, even if it may happen to look like a lozenge from our axis-aligned vantage point.
count_squares([(0, 0), (1, 0), (0, 1), (1, 1)]) == 1 count_squares([(0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2)]) == 6
Checkers Capture by freeman_lex - Imagine a n-by-n chessboard, where your single checker currently stands at position (x, y) and there is pieces - a list that contains the positions of the opponent’s pawns.
Your checker may capture a piece only one step in the four diagonal directions assuming that the square behind the opponent piece in that diagonal direction is vacant. Your checker can then capture that piece by jumping over it into the vacant square, immediately removing that captured piece from the board. The chain of captures continues from the new square, potentially capturing all the pieces in one swoop.
Your function should return the maximum number of pieces that your checker could potentially capture in a single move.
max_checkers_capture(5, (0, 2), [(1, 1), (3, 1), (1, 3)]) == 2 max_checkers_capture(7, (0, 0), [(1, 1), (1, 3), (3, 3), (2, 4), (1, 5)]) == 3
💡ARTICLES:
The articles are about exercise-based Python course and how iteration and garbage collection works under the hood. 📖 Enjoy!
Advanced Python Mastery - An exercise-driven course on Advanced Python Programming that was battle-tested several hundred times on the corporate-training circuit for more than a decade. Written by David Beazley, author of the Python Cookbook, 3rd Edition (O'Reilly) and Python Distilled (Addison-Wesley). Released under a Creative Commons license. Free of ads, tracking, pop-ups, newsletters, and AI.
A taste of iteration in Python - Any object that implements the iterator interface can be used in a for loop, but just how does that work? This article shows you how the iterator protocol is used and how you can write your own compatible objects.
How Python Uses Garbage Collection - This article outlines how Python stores variables as references and how that relates to memory management.
You also need to read all these books to become a good coder! 😎
🙌 Thanks for your attention! Hope to meet you at CheckiO. 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