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))))
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)
import codewars_test as test # TODO Write tests import solution # or from solution import example # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(sum_of_numbers(1, 1), 2)
- import codewars_test as test
- # TODO Write tests
- import solution # or from solution import example
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
test.assert_equals(1 + 1, 2)- test.assert_equals(sum_of_numbers(1, 1), 2)
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/textmatches = re.findall(pattern, text)- pattern = re.compile(r"[aeiouyAEIOUY]")
# Return the number of vowelsreturn len(matches)- def count(text: str) -> int:
- return len(re.findall(pattern, text))