diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2023-05-23 20:35:24 +0200 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2023-05-23 20:35:24 +0200 |
| commit | 7626fcb24af562c8f1d10c951f6fc0338a0df26b (patch) | |
| tree | 1a57de6f5a9b1bb1c80c4324209f47120e98a9aa /challenge-072/lubos-kolouch/python | |
| parent | 1fc2447cb62d692c40a3309f57bce0c92435e14f (diff) | |
| download | perlweeklychallenge-club-7626fcb24af562c8f1d10c951f6fc0338a0df26b.tar.gz perlweeklychallenge-club-7626fcb24af562c8f1d10c951f6fc0338a0df26b.tar.bz2 perlweeklychallenge-club-7626fcb24af562c8f1d10c951f6fc0338a0df26b.zip | |
feat(challenge-072,218/lubos-kolouch/perl,python/): Challenges 072 and 218 LK Perl Python
Diffstat (limited to 'challenge-072/lubos-kolouch/python')
| -rw-r--r-- | challenge-072/lubos-kolouch/python/ch-1.py | 17 | ||||
| -rw-r--r-- | challenge-072/lubos-kolouch/python/ch-2.py | 13 |
2 files changed, 30 insertions, 0 deletions
diff --git a/challenge-072/lubos-kolouch/python/ch-1.py b/challenge-072/lubos-kolouch/python/ch-1.py new file mode 100644 index 0000000000..c61b1f14bc --- /dev/null +++ b/challenge-072/lubos-kolouch/python/ch-1.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def trailing_zeros(n: int) -> int: + count = 0 + i = 5 + while n // i >= 1: + count += n // i + i *= 5 + return count + + +# Test cases: +print(trailing_zeros(10)) # Output: 2 +print(trailing_zeros(7)) # Output: 1 +print(trailing_zeros(4)) # Output: 0 diff --git a/challenge-072/lubos-kolouch/python/ch-2.py b/challenge-072/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..5525686a22 --- /dev/null +++ b/challenge-072/lubos-kolouch/python/ch-2.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + + +def display_lines(file_name: str, a: int, b: int) -> None: + with open(file_name, "r") as file: + lines = file.readlines() + for line in lines[a - 1 : b]: + print(line.strip()) + + +# Suppose 'input.txt' is a file in the same directory with content as described in the problem +display_lines("input.txt", 4, 12) |
