fizzbuzz-kata 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fizzbuzz_kata/core.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
def fizzbuzz(n: int) -> str:
|
|
2
|
+
"""Return the FizzBuzz representation of the integer n.
|
|
3
|
+
|
|
4
|
+
Contract:
|
|
5
|
+
- if n is a multiple of 3 AND 5: "FizzBuzz"
|
|
6
|
+
- if n is a multiple of 3 only: "Fizz"
|
|
7
|
+
- if n is a multiple of 5 only: "Buzz"
|
|
8
|
+
- otherwise: str(n)
|
|
9
|
+
|
|
10
|
+
Raises ValueError if n is not a strictly positive integer.
|
|
11
|
+
"""
|
|
12
|
+
if not isinstance(n, int) or n <= 0:
|
|
13
|
+
raise ValueError("fizzbuzz expects a strictly positive integer")
|
|
14
|
+
|
|
15
|
+
result = ""
|
|
16
|
+
if n % 3 == 0:
|
|
17
|
+
result += "Fizz"
|
|
18
|
+
if n % 5 == 0:
|
|
19
|
+
result += "Buzz"
|
|
20
|
+
return result or str(n)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
fizzbuzz_kata/__init__.py,sha256=SWo96xUO-8jMWQhEHpEYOQSgYSnWSKvL_ump4jnLYjI,103
|
|
2
|
+
fizzbuzz_kata/core.py,sha256=7BsWLxmXBDfJ9tFWz2s7C62zOP_oUXNwp71VynEV2Pw,580
|
|
3
|
+
fizzbuzz_kata-0.1.0.dist-info/METADATA,sha256=iybtEKRJA9Ya_J66axeYDdHT8XY_QHmv5sdwGMbOJK4,224
|
|
4
|
+
fizzbuzz_kata-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
5
|
+
fizzbuzz_kata-0.1.0.dist-info/RECORD,,
|