• Could You Count Visible Discs Properly While Keeping Your Code Clean And Readable?

Hello, checkiomates🐱‍👤!

I welcome you in CheckiO weekly digest. Today we offer you an exercise about counting visible disks of different radius and an article about importance of clear code!

💡TIP

If you find an interesting 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 then "Bookmarks". If you want to discover all CheckiO features, visit our tutorial. It's a longread, but it's worth it!

🏁MISSION

Colorful Disks by freeman_lex -

Colorful Disks is a game played on a base with vertical stick and some paper disks with a hole in the center. The disks all have different radiuses and colors. When all the disks are stacked on top of each other, the number of colors that can be seen from above is the score in this game. So, disks that cannot be seen from above are not scored.

Given the radiuses of the disks in order of placing on the stick (from the bottom one to the top one), calculate the score when all the disks are stacked.

count_discs((3, 6, 7, 4, 5, 1, 2)) == 3
count_discs((6, 5, 4, 3, 2, 1)) == 6
count_discs((5,)) == 1

📖ARTICLE

Clean Code in Python -

Clear code is the cornerstone of efficient and maintainable software development. Its importance lies in its ability to be easily understood and modified by developers, leading to faster debugging, smoother collaboration, and reduced chances of errors. Clear code enhances readability, enabling programmers to grasp its logic swiftly and make necessary adjustments with confidence, fostering a sense of clarity and order within the codebase.

👩‍💻CODE SHOT

How do you think, what the following code does?

def ?????(num: int) -> int: return (9, num%9)[bool(num%9)|(not num)]

🙌 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