mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2024-12-08 00:45:29 +01:00
feat(solutions): add fizzbuzz/python/function
This commit is contained in:
parent
685eeb9de9
commit
70e7c937d0
3
challenges/fizzbuzz/solutions/python/function/README.md
Normal file
3
challenges/fizzbuzz/solutions/python/function/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# fizzbuzz/python/function
|
||||||
|
|
||||||
|
Created by [@Divlo](https://github.com/Divlo) on 30 June 2021.
|
23
challenges/fizzbuzz/solutions/python/function/solution.py
Normal file
23
challenges/fizzbuzz/solutions/python/function/solution.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from typing import List
|
||||||
|
import sys
|
||||||
|
|
||||||
|
input_values: List[str] = []
|
||||||
|
for value in sys.stdin:
|
||||||
|
input_values.append(value.rstrip('\n'))
|
||||||
|
|
||||||
|
|
||||||
|
def fizzbuzz(length: int) -> None:
|
||||||
|
for number in range(1, length + 1, 1):
|
||||||
|
is_divisible_by_3 = number % 3 == 0
|
||||||
|
is_divisible_by_5 = number % 5 == 0
|
||||||
|
if is_divisible_by_3 and is_divisible_by_5:
|
||||||
|
print("FizzBuzz")
|
||||||
|
elif is_divisible_by_3:
|
||||||
|
print("Fizz")
|
||||||
|
elif is_divisible_by_5:
|
||||||
|
print("Buzz")
|
||||||
|
else:
|
||||||
|
print(number)
|
||||||
|
|
||||||
|
|
||||||
|
fizzbuzz(int(input_values[0]))
|
Loading…
Reference in New Issue
Block a user