Post image
Light Mode
Dark Mode
An Importance Of Writing A Readable Code And Playing with Factorial Digits!

Hello, checkiomates๐Ÿฑโ€๐Ÿ‘ค!

For your attention is an article about so called clever code, code golfing and why it's bad from the point of industry-quality code. Today's mission is about counting digits in factorial. Try it!

๐Ÿ’ก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

Factorial Zeros by freeman_lex -

Write a function that finds the number of zeros at the end of the decimal expansion of factorial n!. Because factorials grow very fast, it is not a good strategy to calculate n! and count the zeros.

fact_zeros(2) == 0
fact_zeros(5) == 1
fact_zeros(20) == 4

๐Ÿ“–ARTICLE

Clever code is probably the worst code -

Why code golfing is cool but very far from good code and the clearest code was actually the hardest to write.

๐Ÿ‘ฉโ€๐Ÿ’ปCODE SHOT

How do you think, what the following code does?

def ????????(items: list[int]) -> list[int]:

    for i in range(items.count(0)):
        items.remove(0)
        items.append(0)

    return items

๐Ÿ™Œ 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! โคต

Created: May 27, 2024, 6:25 p.m.
0
41
User avatar
freeman_lex