Kumite (ko͞omiˌtā) is the practice of taking techniques learned from Kata and applying them through the act of freestyle sparring.
You can create a new kumite by providing some initial code and optionally some test cases. From there other warriors can spar with you, by enhancing, refactoring and translating your code. There is no limit to how many warriors you can spar with.
A great use for kumite is to begin an idea for a kata as one. You can collaborate with other code warriors until you have it right, then you can convert it to a kata.
try to format the code properly
Correction of the algorithme
import re def count(text: str) -> int: pattern = r"[aeiouyAEIOUY]" # Find all vowel matches in the string/text matches = re.findall(pattern, text) # Return the number of vowels return len(matches)
- import re
- def count(text: str) -> int:
ctr = 0vowels = ['a', 'e', 'i', 'o', 'u']for letter in text:if letter.lower() in vowels:ctr += 1- pattern = r"[aeiouyAEIOUY]"
- # Find all vowel matches in the string/text
- matches = re.findall(pattern, text)
return ctr- # Return the number of vowels
- return len(matches)
import re import codewars_test as test from solution import count # test.assert_equals(actual, expected, [optional] message) @test.describe("Example") def test_group(): @test.it("test case") def test_case(): test.assert_equals(count('123'), 0) test.assert_equals(count('hi'), 1) test.assert_equals(count('seraph'), 2) test.assert_equals(count('codewarz'), 3) test.assert_equals(count('MissISsIpPi'), 4)
- import re
- import codewars_test as test
- from solution import count
- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
- @test.it("test case")
- def test_case():
- test.assert_equals(count('123'), 0)
- test.assert_equals(count('hi'), 1)
- test.assert_equals(count('seraph'), 2)
- test.assert_equals(count('codewarz'), 3)
- test.assert_equals(count('MissISsIpPi'), 4)
def morse_code(msg: str) -> str: MORSE_DICT = { 'a': '.-', 'b': '-...', 'c': '-.-.', 'd': '-..', 'e': '.', 'f': '..-.', 'g': '--.', 'h': '....', 'i': '..', 'j': '.---', 'k': '-.-', 'l': '.-..', 'm': '--', 'n': '-.', 'o': '---', 'p': '.--.', 'q': '--.-', 'r': '.-.', 's': '...', 't': '-', 'u': '..-', 'v': '...-', 'w': '.--', 'x': '-..-', 'y': '-.--', 'z': '--..', '0': '-----', '1': '.----', '2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...', '8': '---..', '9': '----.', '.': '.-.-.-', ',': '--..--', "'": '.----.', '?': '..--..', ':': '---...', '-': '-....-', '/': '-..-.', '[': '-.--.', '(': '-.--.', ']': '-.--.-', ')': '-.--.-', '"': '.-..-.', '_': '..--.-', '=': '-...-', '+': '.-.-.', '@': '.--.-.', '!': '-.-.--', ' ': '/' } return ' '.join( MORSE_DICT[char] for char in msg.casefold() if char in MORSE_DICT )
def morse_code(msg):"""Morse Code function"""morse_dict = {'a': '.-','b': '-...','c': '-.-.','d': '-..','e': '.','f': '..-.','g': '--.','h': '....','i': '..','j': '.---','k': '-.-','l': '.-..','m': '--','n': '-.','o': '---','p': '.--.','q': '--.-','r': '.-.','s': '...','t': '-','u': '..-','v': '...-','w': '.--','x': '-..-','y': '-.--','z': '--..','0': '-----','1': '.----','2': '..---','3': '...--','4': '....-','5': '.....','6': '-....','7': '--...','8': '---..','9': '----.','.': '.-.-.-',',': '--..--',"'": '.----.','?': '..--..',':': '---...','-': '-....-','/': '-..-.','[': '-.--.','(': '-.--.',']': '-.--.-',')': '-.--.-','"': '.-..-.','_': '..--.-','=': '-...-','+': '.-.-.','@': '.--.-.','!': '-.-.--',' ': '/'- def morse_code(msg: str) -> str:
- MORSE_DICT = {
- 'a': '.-', 'b': '-...', 'c': '-.-.',
- 'd': '-..', 'e': '.', 'f': '..-.',
- 'g': '--.', 'h': '....', 'i': '..',
- 'j': '.---', 'k': '-.-', 'l': '.-..',
- 'm': '--', 'n': '-.', 'o': '---',
- 'p': '.--.', 'q': '--.-', 'r': '.-.',
- 's': '...', 't': '-', 'u': '..-',
- 'v': '...-', 'w': '.--', 'x': '-..-',
- 'y': '-.--', 'z': '--..', '0': '-----',
- '1': '.----', '2': '..---', '3': '...--',
- '4': '....-', '5': '.....', '6': '-....',
- '7': '--...', '8': '---..', '9': '----.',
- '.': '.-.-.-', ',': '--..--', "'": '.----.',
- '?': '..--..', ':': '---...', '-': '-....-',
- '/': '-..-.', '[': '-.--.', '(': '-.--.',
- ']': '-.--.-', ')': '-.--.-', '"': '.-..-.',
- '_': '..--.-', '=': '-...-', '+': '.-.-.',
- '@': '.--.-.', '!': '-.-.--', ' ': '/'
- }
return ' '.join([morse_dict.get(letter) for letter in msg])- return ' '.join(
- MORSE_DICT[char]
- for char in msg.casefold()
- if char in MORSE_DICT
- )
"pick four digit number" "scatter the numbers randomly" "select number" "then what" "then we redo the process and spam emails with the result" "Hahaha ridiculous kumite"
- "pick four digit number"
- "scatter the numbers randomly"
- "select number"
- "then what"
"then we redo the process and spam emails with the result"- "then we redo the process and spam emails with the result"
- "Hahaha ridiculous kumite"