From 949826472a89606cb82ecf5273a55da91dc89b22 Mon Sep 17 00:00:00 2001 From: "Dominik.Poeltl" Date: Mon, 30 Sep 2024 22:28:51 +0200 Subject: [PATCH] 1st commit --- fizzbuzz.py | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 fizzbuzz.py diff --git a/fizzbuzz.py b/fizzbuzz.py new file mode 100644 index 0000000..3cf5a25 --- /dev/null +++ b/fizzbuzz.py @@ -0,0 +1,55 @@ +import numpy as np + +class Solution: + def fizzbuzz(self, n): + result = [] + for i in range(1,n+1): + if i%3 == 0: + if i%5 == 0: + result.append("FizzBuzz") + else: + result.append("Fizz") + elif i%5 == 0: + result.append("Buzz") + else: + result.append(str(i)) + return result + + def fizzbuzz2(self, n, div1, div2): + result = [] + for i in range (1, n+1): + if i%div1 == 0 and i%div2 == 0: + result.append("FizzBuzz") + elif i%div1 == 0: + result.append("Fizz") + elif i%div2 == 0: + result.append("Buzz") + else: + result.append(str(i)) + return result + +obj = Solution() +div1 = 2 +div2 = 10 +print(obj.fizzbuzz(30)) +print(obj.fizzbuzz2(30, div1, div2)) + +""" +class Solution(object): + def fizzBuzz(self, n): + :type n: int + :rtype: List[str] + result = [] + for i in range(1,n+1): + if i% 3== 0 and i%5==0: + result.append("FizzBuzz") + elif i %3==0: + result.append("Fizz") + elif i% 5 == 0: + result.append("Buzz") + else: + result.append(str(i)) + return result +ob1 = Solution() +print(ob1.fizzBuzz(30)) +"""