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.
const cinema_auditorium = (spisok2d, ryad) => { console.log(spisok2d, ryad); let totalsoldtickets = 0; for(let i = 0; i < spisok2d.length; i++) { for(let j = 0; j < spisok2d[i].length; j++) { if(spisok2d[i][j] === 1 && i === ryad) { totalsoldtickets++; } } } return totalsoldtickets; }
const cinema_auditorium = (spisok2D,ryad)=> {console.log(spisok2D,ryad)return 4- const cinema_auditorium = (spisok2d, ryad) => {
- console.log(spisok2d, ryad);
- let totalsoldtickets = 0;
- for(let i = 0; i < spisok2d.length; i++) {
- for(let j = 0; j < spisok2d[i].length; j++) {
- if(spisok2d[i][j] === 1 && i === ryad) {
- totalsoldtickets++;
- }
- }
- }
- return totalsoldtickets;
- }
Improvements
# Effectively works with everything def new_expect_error(function, exception=Exception, message = "{} did not raise an exception of {}", parameters = []) -> bool: if not(isinstance(function, type(lambda:[])) and isinstance(exception, Exception) and isinstance(message, str) and isinstance(parameters, list)): raise TypeError('parameters input problem') try: if parameters==[]: function(*parameters) else: function() except exception: return True return False
# BaseException >> Exceptiondef f1(): raise Exception()- # Effectively works with everything
# BaseException >> Exception >> ArithmeticError >> ZeroDivisionErrordef f2(): return 1 // 0# BaseException >> Exception >> LookupError >> KeyErrordef f3(): return {}[1]def f0(): pass- def new_expect_error(function, exception=Exception, message = "{} did not raise an exception of {}", parameters = []) -> bool:
- if not(isinstance(function, type(lambda:[])) and isinstance(exception, Exception) and isinstance(message, str) and isinstance(parameters, list)):
- raise TypeError('parameters input problem')
- try:
- if parameters==[]:
- function(*parameters)
- else:
- function()
- except exception:
- return True
- return False
@test.describe('expect_error is backwards compatible') def d1(): for f in (new_expect_error,): test.expect_error('Should raise something', f) excn = ('Exception', 'ArithmeticError', 'ZeroDivisionError', 'LookupError', 'KeyError', 'OSError') exc = (Exception, ArithmeticError, ZeroDivisionError, LookupError, KeyError, OSError) @test.describe('expect_error with exception class') def d2(): @test.it('new_expect_error raises nothing') def i0(): test.expect_error('new_expect_error did not raise any exception', new_expect_error) for i in range(6): test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i]) @test.it('new_expect_error raises Exception') def i1(): test.expect_error('new_expect_error did not raise Exception', new_expect_error) for i in range(6): test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i]) @test.it('new_expect_error raises Exception >> ArithmeticError >> ZeroDivisionError') def i2(): test.expect_error('new_expect_error did not raise Exception', new_expect_error) for i in range(6): test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i]) @test.it('new_expect_error raises Exception >> LookupError >> KeyError') def i3(): test.expect_error('new_expect_error did not raise Exception', new_expect_error) for i in range(6): test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i]) @test.it('Testing with multiple exception types') def i4(): test.expect_error('new_expect_error did not raise one of ArithmeticError or KeyError', new_expect_error, (ArithmeticError, KeyError)) test.expect_error('new_expect_error did not raise one of LookupError or OSError', new_expect_error, (LookupError, OSError)) test.expect_error('new_expect_error did not raise one of LookupError or OSError', new_expect_error, (LookupError, OSError))
- @test.describe('expect_error is backwards compatible')
- def d1():
for f in (f0, f1, f2, f3):- for f in (new_expect_error,):
- test.expect_error('Should raise something', f)
- excn = ('Exception', 'ArithmeticError', 'ZeroDivisionError', 'LookupError', 'KeyError', 'OSError')
- exc = (Exception, ArithmeticError, ZeroDivisionError, LookupError, KeyError, OSError)
- @test.describe('expect_error with exception class')
- def d2():
@test.it('f0 raises nothing')- @test.it('new_expect_error raises nothing')
- def i0():
test.expect_error('f0 did not raise any exception', f0)- test.expect_error('new_expect_error did not raise any exception', new_expect_error)
- for i in range(6):
test.expect_error('f0 did not raise {}'.format(excn[i]), f0, exc[i])@test.it('f1 raises Exception')- test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i])
- @test.it('new_expect_error raises Exception')
- def i1():
test.expect_error('f1 did not raise Exception', f1)- test.expect_error('new_expect_error did not raise Exception', new_expect_error)
- for i in range(6):
test.expect_error('f1 did not raise {}'.format(excn[i]), f1, exc[i])@test.it('f2 raises Exception >> ArithmeticError >> ZeroDivisionError')- test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i])
- @test.it('new_expect_error raises Exception >> ArithmeticError >> ZeroDivisionError')
- def i2():
test.expect_error('f2 did not raise Exception', f2)- test.expect_error('new_expect_error did not raise Exception', new_expect_error)
- for i in range(6):
test.expect_error('f2 did not raise {}'.format(excn[i]), f2, exc[i])@test.it('f3 raises Exception >> LookupError >> KeyError')- test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i])
- @test.it('new_expect_error raises Exception >> LookupError >> KeyError')
- def i3():
test.expect_error('f3 did not raise Exception', f3)- test.expect_error('new_expect_error did not raise Exception', new_expect_error)
- for i in range(6):
test.expect_error('f3 did not raise {}'.format(excn[i]), f3, exc[i])- test.expect_error('new_expect_error did not raise {}'.format(excn[i]), new_expect_error, exc[i])
- @test.it('Testing with multiple exception types')
- def i4():
test.expect_error('f2 did not raise one of ArithmeticError or KeyError',f2, (ArithmeticError, KeyError))test.expect_error('f3 did not raise one of LookupError or OSError',f3, (LookupError, OSError))test.expect_error('f0 did not raise one of LookupError or OSError',f0, (LookupError, OSError))- test.expect_error('new_expect_error did not raise one of ArithmeticError or KeyError',
- new_expect_error, (ArithmeticError, KeyError))
- test.expect_error('new_expect_error did not raise one of LookupError or OSError',
- new_expect_error, (LookupError, OSError))
- test.expect_error('new_expect_error did not raise one of LookupError or OSError',
- new_expect_error, (LookupError, OSError))
greeting=Greeting=lambda name,rank='',formal=False:"He{0}, {1}{2}{3}{4}".format(('y','llo')[formal],rank*formal,' '*bool(rank and formal),name,'!.'[formal])
def Greeting(n, rank='', formal=False):determinant = f'{rank} {n}' if formal and rank else f'{n}'return f"Hello, {determinant}." if formal else f"Hey, {determinant}!"- greeting=Greeting=lambda name,rank='',formal=False:"He{0}, {1}{2}{3}{4}".format(('y','llo')[formal],rank*formal,' '*bool(rank and formal),name,'!.'[formal])
import codewars_test as test from solution import Greeting import random def get_greeting(name, rank=None, formal=False): print(f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!') return f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!' names = [ 'Lisa', 'Skylar', 'Dylan', 'Harper', 'Susan', 'Kenneth', 'Quinn', 'Kevin', 'Morgan', 'Jordan', 'Finley', 'Karen', 'Michael', 'Emerson', 'Daniel', 'Avery', 'William', 'Michelle', 'Justice', 'David', 'Donald', 'Richard', 'Jennifer', 'Robert', 'Payton', 'John', 'James', 'Ariel', 'Skyler', 'Dorothy', 'Charles', 'Paul', 'Drew', 'Rory', 'Steven', 'Riley', 'Reese', 'Robin', 'Cameron', 'Mark', 'Jamie', 'Sarah', 'Jessica', 'Nancy', 'Anthony', 'Brian', 'Sandra', 'George', 'Helen', 'Melissa', 'Dakota', 'Mary', 'Alexis', 'Peyton', 'Alex', 'Charlie', 'Matthew', 'Patricia', 'Christopher', 'Edward', 'Elizabeth', 'Amanda', 'Sawyer', 'Margaret', 'Donna', 'Emily', 'Thomas', 'Bailey', 'Hayden', 'Rowan', 'Harley', 'Kai', 'Carol', 'Laura', 'Linda', 'Casey', 'Parker', 'Andrew', 'Joseph', 'Reagan', 'Emery', 'Phoenix', 'Taylor', 'Betty' ] titles = [ 'Duchess', 'Ambassador', 'Mistress', 'Executive', 'Sultan', 'Pharaoh', 'Baron', 'Mayor', 'Magistrate', 'Sergeant', 'Doctor', 'Sir', 'Lord', 'Vice President', 'Baroness', 'Cardinal', 'Officer', 'Archbishop', 'Duke', 'Agent', 'Madam', 'Queen', 'Minister', 'King', 'Captain', 'Pope', 'Master', 'Admiral', 'Princess', 'Lieutenant', 'Director', 'President', 'Governor', 'Commander', 'Prince', 'Detective', 'Professor', 'Sheikh', 'Bishop', 'Chancellor', 'Countess', 'Empress', 'Chief', 'Senator', 'Counselor', 'Emperor', 'Judge', 'General', 'Count' ] @test.describe("Fixed Tests") def test_group(): @test.it("Tests") def test_case(): test.assert_equals(Greeting('John'), 'Hey, John!') test.assert_equals(Greeting('Churchill', 'Sir', True), 'Hello, Sir Churchill.') test.assert_equals(Greeting('Einstein', 'Proffessor', False), 'Hey, Einstein!') test.assert_equals(Greeting('Jane', formal=True), 'Hello, Jane.') @test.describe("Random Tests") def random(): for test_number in range(100): qname = names[random.randint(0,len(names)-1)] qrank = titles[random.randint(0,len(titles)-1)] if random.randint(0,1)==1 else '' f = bool(random.randint(0,1)==0) @test.it(f'Random Test #{str(test_number+1)}: {qname}{", rank="+qrank if not qrank=="" else ""}, formal={f}') def _(): expected = f'Hello,{" "if not qrank=="" else ""}{qrank} {qname}.' if f else f'Hey, {qname}!' print(f'Expected Answer: "{expected}". Your Answer: "{Greeting(qname, qrank, f)}"') test.assert_equals(Greeting(qname, qrank, f), expected)
- import codewars_test as test
- from solution import Greeting
- import random
- def get_greeting(name, rank=None, formal=False):
- print(f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!')
- return f'Hello,{" " + rank if rank is not None else ""} {name}.' if formal else f'Hey, {name}!'
- names = [
- 'Lisa', 'Skylar', 'Dylan', 'Harper', 'Susan', 'Kenneth', 'Quinn', 'Kevin', 'Morgan', 'Jordan', 'Finley',
- 'Karen', 'Michael', 'Emerson', 'Daniel', 'Avery', 'William', 'Michelle', 'Justice', 'David', 'Donald',
- 'Richard', 'Jennifer', 'Robert', 'Payton', 'John', 'James', 'Ariel', 'Skyler', 'Dorothy', 'Charles', 'Paul',
- 'Drew', 'Rory', 'Steven', 'Riley', 'Reese', 'Robin', 'Cameron', 'Mark', 'Jamie', 'Sarah', 'Jessica', 'Nancy',
- 'Anthony', 'Brian', 'Sandra', 'George', 'Helen', 'Melissa', 'Dakota', 'Mary', 'Alexis', 'Peyton', 'Alex',
- 'Charlie', 'Matthew', 'Patricia', 'Christopher', 'Edward', 'Elizabeth', 'Amanda', 'Sawyer', 'Margaret',
- 'Donna', 'Emily', 'Thomas', 'Bailey', 'Hayden', 'Rowan', 'Harley', 'Kai', 'Carol', 'Laura', 'Linda', 'Casey',
- 'Parker', 'Andrew', 'Joseph', 'Reagan', 'Emery', 'Phoenix', 'Taylor', 'Betty'
- ]
- titles = [
- 'Duchess', 'Ambassador', 'Mistress', 'Executive', 'Sultan', 'Pharaoh', 'Baron', 'Mayor', 'Magistrate',
- 'Sergeant', 'Doctor', 'Sir', 'Lord', 'Vice President', 'Baroness', 'Cardinal', 'Officer', 'Archbishop',
- 'Duke', 'Agent', 'Madam', 'Queen', 'Minister', 'King', 'Captain', 'Pope', 'Master', 'Admiral', 'Princess',
- 'Lieutenant', 'Director', 'President', 'Governor', 'Commander', 'Prince', 'Detective', 'Professor',
- 'Sheikh', 'Bishop', 'Chancellor', 'Countess', 'Empress', 'Chief', 'Senator', 'Counselor', 'Emperor', 'Judge',
- 'General', 'Count'
- ]
- @test.describe("Fixed Tests")
- def test_group():
- @test.it("Tests")
- def test_case():
- test.assert_equals(Greeting('John'), 'Hey, John!')
- test.assert_equals(Greeting('Churchill', 'Sir', True), 'Hello, Sir Churchill.')
- test.assert_equals(Greeting('Einstein', 'Proffessor', False), 'Hey, Einstein!')
- test.assert_equals(Greeting('Jane', formal=True), 'Hello, Jane.')
- @test.describe("Random Tests")
- def random():
- for test_number in range(100):
- qname = names[random.randint(0,len(names)-1)]
- qrank = titles[random.randint(0,len(titles)-1)] if random.randint(0,1)==1 else ''
- f = bool(random.randint(0,1)==0)
- @test.it(f'Random Test #{str(test_number+1)}: {qname}{", rank="+qrank if not qrank=="" else ""}, formal={f}')
- def _():
- expected = f'Hello,{" "if not qrank=="" else ""}{qrank} {qname}.' if f else f'Hey, {qname}!'
- print(f'Expected Answer: "{expected}". Your Answer: "{Greeting(qname, qrank, f)}"')
- test.assert_equals(Greeting(qname, qrank, f), expected)
reverse_string = lambda s: s[::-1]
def reverse_string(s):return s[::-1]- reverse_string = lambda s: s[::-1]
import codewars_test as test from solution import reverse_string @test.describe("Solution") def a(): @test.it("should test for something") def a(): test.assert_equals(reverse_string('abc'), 'cba') test.assert_equals(reverse_string('123'), '321') test.assert_equals(reverse_string('a1b2c3'), '3c2b1a') test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH') test.assert_equals(reverse_string('Lorem ipsum dolor sit amet!'), '!tema tis rolod muspi meroL')
- import codewars_test as test
- from solution import reverse_string
- @test.describe("Solution")
- def a():
- @test.it("should test for something")
- def a():
- test.assert_equals(reverse_string('abc'), 'cba')
- test.assert_equals(reverse_string('123'), '321')
- test.assert_equals(reverse_string('a1b2c3'), '3c2b1a')
- test.assert_equals(reverse_string('Hello World!'), '!dlroW olleH')
import re def longest_words(word_list, num_words): if not isinstance(word_list, list) or not isinstance(num_words, int) or num_words < 0: return 'Invalid Parameters' valid_words = [re.sub(r'[^A-Za-z]', '', word) for word in word_list if word and re.sub(r'[^A-Za-z]', '', word)] return sorted(valid_words, key=len, reverse=True)[:num_words] if num_words <= len(valid_words) else 'Invalid Parameters'
- import re
def longest_words(array, num):valid_words = [re.sub(r'[^A-Za-z]', '', word) for word in array if word and re.sub(r'[^A-Za-z]', '', word)]return sorted(valid_words, key=len, reverse=True)[:num] if num <= len(valid_words) else 'Invalid Parameters'- def longest_words(word_list, num_words):
- if not isinstance(word_list, list) or not isinstance(num_words, int) or num_words < 0:
- return 'Invalid Parameters'
- valid_words = [re.sub(r'[^A-Za-z]', '', word) for word in word_list if word and re.sub(r'[^A-Za-z]', '', word)]
- return sorted(valid_words, key=len, reverse=True)[:num_words] if num_words <= len(valid_words) else 'Invalid Parameters'
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)
- import codewars_test as test
from solution import longest_wordsimport random- # TODO Write tests
- import solution # or from solution import example
# Working solutiondef _solve(array, num):new = [k for k in sorted([''.join([i for i in j if 97 <= ord(i) <= 122 or 65 <= ord(i) <= 90]) for j in array], key=lambda x: len(x), reverse=True) if k != '']print(new[:num] if num <= len(new) else 'Invalid Parameters')return new[:num] if num <= len(new) else 'Invalid Parameters'# Random word list generatordef gen_random(length):word_list = [('Programming', 'ƤŖø¶Ŗ@µµƗƕ¶', 'Prø¶r@mming'), ('is', 'Ɨ$', 'is'), ('often', 'øƒƮƩƕ', 'often'),('compared', '¢øµƤ@ŖƩƊ', 'comƤ@Ŗed'), ('to', 'Ʈø', 'to'), ('solving', '$øȴƔƗƕ¶', '$olvƗn¶'),('intricate', 'ƗƕƮŖƗ¢@ƮƩ', 'intri¢aƮe'), ('puzzles,', 'Ƥû§§ȴƩ$,', 'pu§§le$,'), ('', '', '',),('requiring', 'ŖƩǭûƗŖƗƕ¶', 'ŖeqûƗŖing'), ('a', '@', 'a'), ('sharp', '$ɧ@ŖƤ', 'sharp'),('analytical', '@ƕ@ȴ¥ƮƗ¢@ȴ', '@nal¥Ʈical'), ('mind', 'µƗƕƊ', 'mind'), ('to', 'Ʈø', 'tø'),('piece', 'ƤƗƩ¢Ʃ', 'piecƩ'), ('together', 'Ʈø¶ƩƮɧƩŖ', 'togetɧeŖ'), ('the', 'ƮɧƩ', 'the'),('correct', '¢øŖŖƩ¢Ʈ', 'correct'), ('code.', '¢øƊƩ.', 'code.'), ('One', 'øƕƩ', 'Oƕe'), ('of', 'øƒ', 'oƒ'),('the', 'ƮɧƩ', 'tɧe'), ('complexities', '¢øµƤȴƩ×ƗƮƗƩ$', 'cøµplexƗƮie$'), ('of', 'øƒ', 'of'),('programming', 'ƤŖø¶Ŗ@µµƗƕ¶', 'ƤrogrammƗng'), ('lies', 'ȴƗƩ$', 'liƩs'), ('in', 'Ɨƕ', 'in'),('managing', 'µ@ƕ@¶Ɨƕ¶', 'µaƕagƗn¶'), ('an', '@ƕ', '@n'), ('ever-growing', 'ƩƔƩŖ-¶ŖøƜƗƕ¶', 'eƔƩr-¶røƜing'),('body', 'ßøƊ¥', 'body'), ('of', 'øƒ', 'oƒ'), ('knowledge', 'ƙƕøƜȴƩƊ¶Ʃ', 'kƕoƜledge'), ('as', '@$', 'as'),('new', 'ƕƩƜ', 'nƩw'), ('languages', 'ȴ@ƕ¶û@¶Ʃ$', 'laƕgû@ges'), ('and', '@ƕƊ', '@nd'),('technologies', 'ƮƩ¢ɧƕøȴø¶ƗƩ$', 'technoløgies'), ('emerge.', 'ƩµƩŖ¶Ʃ.', 'emergƩ.'), ('', '', '',),('Debugging', 'ƊƩßû¶¶Ɨƕ¶', 'Ɗeßûg¶ing'), ('code', '¢øƊƩ', 'cøde'), ('can', '¢@ƕ', 'can'),('be', 'ßƩ', 'be'), ('like', 'ȴƗƙƩ', 'ȴikƩ'), ('searching', '$Ʃ@Ŗ¢ɧƗƕ¶', 'se@rcɧƗn¶'), ('for', 'ƒøŖ', 'for'),('a', '@', 'a'), ('needle', 'ƕƩƩƊȴƩ', 'ƕeƩdle'), ('in', 'Ɨƕ', 'Ɨn'), ('a', '@', 'a'),('haystack,', 'ɧ@¥$Ʈ@¢ƙ,', 'haystacƙ,'), ('as', '@$', '@s'), ('a', '@', 'a'), ('single', '$Ɨƕ¶ȴƩ', 'siƕgle'),('character', '¢ɧ@Ŗ@¢ƮƩŖ', 'cɧaŖ@cteŖ'), ('error', 'ƩŖŖøŖ', 'errør'), ('can', '¢@ƕ', 'caƕ'),('lead', 'ȴƩ@Ɗ', 'lƩ@Ɗ'), ('to', 'Ʈø', 'tø'), ('hours', 'ɧøûŖ$', 'hoûŖ$'), ('of', 'øƒ', 'oƒ'),('troubleshooting.', 'ƮŖøûßȴƩ$ɧøøƮƗƕ¶.', 'trøußlesɧooƮin¶.'), ('The', 'ƮɧƩ', 'Ʈhe'), ('', '', '',), ('', '', '',),('meticulous', 'µƩƮƗ¢ûȴøû$', 'metƗ¢uȴous'), ('attention', '@ƮƮƩƕƮƗøƕ', 'aƮtention'), ('to', 'Ʈø', 'to'),('detail', 'ƊƩƮ@Ɨȴ', 'detail'), ('needed', 'ƕƩƩƊƩƊ', 'nƩedƩd'), ('in', 'Ɨƕ', 'in'), ('', '', '',),('programming', 'ƤŖø¶Ŗ@µµƗƕ¶', 'Ƥro¶rammƗng'), ('can', '¢@ƕ', '¢an'), ('be', 'ßƩ', 'be'), ('', '', '',),('mentally', 'µƩƕƮ@ȴȴ¥', 'mƩnƮ@ȴȴy'), ('taxing,', 'Ʈ@×Ɨƕ¶,', 'Ʈ@xƗng,'), ('leading', 'ȴƩ@ƊƗƕ¶', 'ȴe@dƗng'),('to', 'Ʈø', 'to'), ('fatigue', 'ƒ@ƮƗ¶ûƩ', 'fatiguƩ'), ('and', '@ƕƊ', 'aƕd'), ('burnout.', 'ßûŖƕøûƮ.', 'ßuŖnoût.'),('Staying', '$Ʈ@¥Ɨƕ¶', '$taying'), ('updated', 'ûƤƊ@ƮƩƊ', 'upd@teƊ'), ('in', 'Ɨƕ', 'iƕ'), ('the', 'ƮɧƩ', 'tɧe'),('fast-paced', 'ƒ@$Ʈ-Ƥ@¢ƩƊ', 'fa$t-ƤacƩƊ'), ('tech', 'ƮƩ¢ɧ', 'tech'), ('world', 'ƜøŖȴƊ', 'wørȴƊ'), ('is', 'Ɨ$', 'is'),('a', '@', 'a'), ('constant', '¢øƕ$Ʈ@ƕƮ', 'con$Ʈaƕt'), ('challenge,', '¢ɧ@ȴȴƩƕ¶Ʃ,', 'ch@lleƕge,'), ('', '', '',),('with', 'ƜƗƮɧ', 'ƜiƮh'), ('new', 'ƕƩƜ', 'new'), ('frameworks', 'ƒŖ@µƩƜøŖƙ$', 'ƒŖ@meƜoŖks'), ('and', '@ƕƊ', '@nd'),('libraries', 'ȴƗßŖ@ŖƗƩ$', 'ȴƗbŖ@rƗes'), ('being', 'ßƩƗƕ¶', 'bƩƗƕ¶'), ('released', 'ŖƩȴƩ@$ƩƊ', 'rƩle@sƩƊ'),('regularly.', 'ŖƩ¶ûȴ@Ŗȴ¥.', 'ŖƩguȴarly.'), ('The', 'ƮɧƩ', 'ƮhƩ'), ('precise', 'ƤŖƩ¢Ɨ$Ʃ', 'precise'),('syntax', '$¥ƕƮ@×', 's¥nƮax'), ('and', '@ƕƊ', 'anƊ'), ('semantics', '$Ʃµ@ƕƮƗ¢$', 'seµaƕƮƗc$'), ('of', 'øƒ', 'of'),('each', 'Ʃ@¢ɧ', 'e@cɧ'), ('programming', 'ƤŖø¶Ŗ@µµƗƕ¶', 'pŖogŖamµing'), ('language', 'ȴ@ƕ¶û@¶Ʃ', 'ȴ@ngua¶e'),('add', '@ƊƊ', '@dd'), ('layers', 'ȴ@¥ƩŖ$', 'layƩr$'), ('of', 'øƒ', 'of'), ('difficulty,', 'ƊƗƒƒƗ¢ûȴƮ¥,', 'diƒfƗcûlty,'),('as', '@$', 'as'), ('small', '$µ@ȴȴ', 'smaȴȴ'), ('mistakes', 'µƗ$Ʈ@ƙƩ$', 'mƗstaƙe$'), ('can', '¢@ƕ', 'can'),('cause', '¢@û$Ʃ', 'caûsƩ'), ('major', 'µ@ǰøŖ', 'µ@ǰøŖ'), ('issues.', 'Ɨ$$ûƩ$.', 'Ɨ$sûes.'), ('', '', '',)]return [random.choice(word_list)[random.randint(0, 2)] for _ in range(length)]# Start of testing@test.describe("Example Tests")- # test.assert_equals(actual, expected, [optional] message)
- @test.describe("Example")
- def test_group():
@test.it("Testing...")- @test.it("test case")
- def test_case():
test.assert_equals(longest_words(["Hello", "world", "Coding", "is", "fun!"], 1), ['Coding'])test.assert_equals(longest_words(["Python", "Java", "C++", "JavaScript"], 4), ['JavaScript', 'Python', 'Java', 'C'])test.assert_equals(longest_words(["Hello", "world", "Coding", "is", "fun!"], 6), 'Invalid Parameters')@test.describe("Edge Cases")def test_group2():@test.it("Testing...")def test_edges():test.assert_equals(longest_words(["H3ll0", "w0rld", "C0d1ng", "1s", "fun!"], 4), ['wrld', 'Cdng', 'Hll', 'fun'])test.assert_equals(longest_words(["HELLO", '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 1), ['HELLO'])test.assert_equals(longest_words(["HELLO", 'B123I123G123W123O123R123D', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 2), ['BIGWORD', 'HELLO'])test.assert_equals(longest_words(["HELLO", '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], 2), 'Invalid Parameters')test.assert_equals(longest_words(['k', 'j', 'i', 'h', 'g', 'f', 'e', 'd', 'c', 'b', 'a'], 5), ['k', 'j', 'i', 'h', 'g'])@test.describe('Random Tests')def test_random():@test.it('Small Tests')def small_rand():for _ in range(10):for i in range(5, 10):rand_words = gen_random(i)rand_num = random.randint(0, i + 1)test.assert_equals(longest_words(rand_words[:], rand_num), _solve(rand_words[:], rand_num))@test.it('Medium Tests')def med_rand():for _ in range(10):for i in range(15, 20):rand_words = gen_random(i)rand_num = random.randint(0, i + 1)test.assert_equals(longest_words(rand_words[:], rand_num), _solve(rand_words[:], rand_num))@test.it('Large Tests')def med_rand():for i in range(25, 125):rand_words = gen_random(i)rand_num = random.randint(0, i + 1)test.assert_equals(longest_words(rand_words[:], rand_num), _solve(rand_words[:], rand_num))- test.assert_equals(1 + 1, 2)