Ad
Code
Diff
  • def bool_to_word(param):  
        return ("No", "Yes")[param]
    
    • def bool_to_word(param):
    • return {True: "Yes", False: "No"}[param]
    • return ("No", "Yes")[param]
Code
Diff
  • class MaxDigit:
        def __init__(self, n):
            self.n = n
    
        def execute(self):
            return sum(10**i * int(n) for i, n in enumerate(sorted(str(self.n))))
    • class MaxDigit:
    • def __init__(self, n):
    • self.n = n
    • def execute(self):
    • return int(''.join((sorted([n for n in str(self.n)], reverse=True))))
    • return sum(10**i * int(n) for i, n in enumerate(sorted(str(self.n))))
Code
Diff
  • import random
    
    def sum_of_numbers(a, b):
        if random.random() < 0.01:
            return a + b
        else:
            return sum_of_numbers(a, b)
    • import random
    • def sum_of_numbers(a, b):
    • return b + a
    • if random.random() < 0.01:
    • return a + b
    • else:
    • return sum_of_numbers(a, b)
Code
Diff
  • #If it is not true currently, I shall make it true
    def above_two(arg):
        arg = 3
        return arg > 2
    • #If it is not true currently, I shall make it true
    • def above_two(arg):
    • if not(arg > 2):
    • while not(arg > 2):
    • arg += 1
    • return True
    • pass
    • else:
    • return True
    • arg = 3
    • return arg > 2
Code
Diff
  • import re
    
    pattern = re.compile(r"[aeiouyAEIOUY]")
    
    def count(text: str) -> int:
        return len(re.findall(pattern, text))
    • import re
    • def count(text: str) -> int:
    • pattern = r"[aeiouyAEIOUY]"
    • # Find all vowel matches in the string/text
    • matches = re.findall(pattern, text)
    • pattern = re.compile(r"[aeiouyAEIOUY]")
    • # Return the number of vowels
    • return len(matches)
    • def count(text: str) -> int:
    • return len(re.findall(pattern, text))
Code
Diff
  • def multiply_and_add_one(a, b):
        return a * b + 1
    • def multiply_and_add_one(a, b):
    • r = a * b
    • return r + 1
    • return a * b + 1