Post image
Light Mode
Dark Mode
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! โคต

Created: May 14, 2024, 12:15 p.m.
1
40
User avatar
freeman_lex