commit 949826472a89606cb82ecf5273a55da91dc89b22 Author: Dominik.Poeltl Date: Mon Sep 30 22:28:51 2024 +0200 1st commit 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)) +"""