Fundamentals

The tests don't provide for this. I don't know how to fix it :/

Code
Diff
  • import random as r 
    
    class Dice:
        def __init__(self, faces):self.faces = r.choice(faces)
            
        def __call__(self):return self.faces
            
        
    dice = Dice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"])
    • import random as r
    • class Dice:
    • def __init__(self, faces):
    • self.faces = faces
    • def roll(self):
    • return r.choice(self.faces)
    • def __init__(self, faces):self.faces = r.choice(faces)
    • def __call__(self):return self.faces
    • dice = Dice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"])
    • d = lambda :dice.roll()
    • dice = Dice(["⚀", "⚁", "⚂", "⚃", "⚄", "⚅"])

Why use extra 4 bytes :D

Code
Diff
  • int sum_of_numbers(int a, int b)
    {
      return a + b;
    }
    • int sum_of_numbers(int a, int b)
    • {
    • int sum=a+b;
    • return sum;
    • return a + b;
    • }
Code
Diff
  • class IsPrimeNumber:
        """Returns True if n is a prime number, False otherwise"""
    
        def __init__(self, n):
            self.n = n
    
        def calculate(self):
            if self.n > 1:
                for i in range(2, int(self.n ** 0.5) + 1): 
                    if self.n % i == 0:
                        return False
                return True  # If no divisors found, it's prime
            return False
    
    
    class Fizz(IsPrimeNumber):
        """Returns True if n is divisible by 3, False otherwise"""
    
        def calculate(self):
            return self.n % 3 == 0
    
    
    class Buzz(IsPrimeNumber):
        """Returns True if n is divisible by 5, False otherwise"""
    
        def calculate(self):
            return self.n % 5 == 0
    
    
    class FizzBuzz(IsPrimeNumber):
        """Returns True if n is divisible by 3 and 5, False otherwise"""
    
        def calculate(self):
            return Fizz(self.n).calculate() and Buzz(self.n).calculate()
    
    
    class CodeWarKata776:
        """Executes the Fizz, Bizz, FizzBuzz Prime sequence."""
        def __init__(self, n):
            self.n = n
    
        def calculate_prime(self):
            return IsPrimeNumber(self.n).calculate()
    
        def calculate_fizz(self):
            return Fizz(self.n).calculate()
    
        def calculate_buzz(self):
            return Buzz(self.n).calculate()
    
        def calculate_fizzbuzz(self):
            return FizzBuzz(self.n).calculate()
    
        def execute(self):
            if IsPrimeNumber(self.n).calculate():
                return 'Prime'
            if FizzBuzz(self.n).calculate():
                return 'FizzBuzz'
            elif Fizz(self.n).calculate():
                return 'Fizz'
            elif Buzz(self.n).calculate():
                return 'Buzz'
            return self.n
    • class IsPrimeNumber:
    • """Returns True if n is a prime number, False otherwise"""
    • def __init__(self, n):
    • self.n = n
    • def calculate(self):
    • if self.n > 1:
    • for i in range(2, int(self.n ** 0.5) + 1):
    • if self.n % i == 0:
    • return False
    • return True # If no divisors found, it's prime
    • else:
    • return False
    • return False
    • class Fizz:
    • class Fizz(IsPrimeNumber):
    • """Returns True if n is divisible by 3, False otherwise"""
    • def __init__(self, n):
    • self.n = n
    • def calculate(self):
    • return self.n % 3 == 0
    • class Buzz:
    • class Buzz(IsPrimeNumber):
    • """Returns True if n is divisible by 5, False otherwise"""
    • def __init__(self, n):
    • self.n = n
    • def calculate(self):
    • return self.n % 5 == 0
    • class FizzBuzz:
    • class FizzBuzz(IsPrimeNumber):
    • """Returns True if n is divisible by 3 and 5, False otherwise"""
    • def __init__(self, n):
    • self.n = n
    • def calculate(self):
    • return Fizz(self.n).calculate() and Buzz(self.n).calculate()
    • class CodeWarKata776:
    • """Executes the Fizz, Bizz, FizzBuzz Prime sequence."""
    • def __init__(self, n):
    • self.n = n
    • def calculate_prime(self):
    • return IsPrimeNumber(self.n).calculate()
    • def calculate_fizz(self):
    • return Fizz(self.n).calculate()
    • def calculate_buzz(self):
    • return Buzz(self.n).calculate()
    • def calculate_fizzbuzz(self):
    • return FizzBuzz(self.n).calculate()
    • def execute(self):
    • if IsPrimeNumber(self.n).calculate():
    • return 'Prime'
    • if FizzBuzz(self.n).calculate():
    • return 'FizzBuzz'
    • elif Fizz(self.n).calculate():
    • return 'Fizz'
    • elif Buzz(self.n).calculate():
    • return 'Buzz'
    • else:
    • return self.n
    • return self.n
Code
Diff
  • def func_to_var(func): return func()
    • def func_to_var(func):
    • me = func()
    • return me
    • def func_to_var(func): return func()
Code
Diff
  • def multiply_and_add_one(a, b): return (a * b) + 1
        
    
    • def multiply_and_add_one(a, b):
    • return (a * b) + 1
    • def multiply_and_add_one(a, b): return (a * b) + 1