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.
// # def multiply (a,b): // # return a * b multiply = (a, b) => a * b;
def multiply (a,b):return a * b- // # def multiply (a,b):
- // # return a * b
- multiply = (a, b) => a * b;
// Since Node 10, we're using Mocha. // You can use `chai` for assertions. const chai = require("chai"); const assert = chai.assert; // Uncomment the following line to disable truncating failure messages for deep equals, do: // chai.config.truncateThreshold = 0; // Since Node 12, we no longer include assertions from our deprecated custom test framework by default. // Uncomment the following to use the old assertions: // const Test = require("@codewars/test-compat"); describe("Solution", function() { it("should test for something", function() { // Test.assertEquals(1 + 1, 2); // assert.strictEqual(1 + 1, 2); }); });
import codewars_test as test# TODO Write testsimport solution # or from solution import example- // Since Node 10, we're using Mocha.
- // You can use `chai` for assertions.
- const chai = require("chai");
- const assert = chai.assert;
- // Uncomment the following line to disable truncating failure messages for deep equals, do:
- // chai.config.truncateThreshold = 0;
- // Since Node 12, we no longer include assertions from our deprecated custom test framework by default.
- // Uncomment the following to use the old assertions:
- // const Test = require("@codewars/test-compat");
# 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)- describe("Solution", function() {
- it("should test for something", function() {
- // Test.assertEquals(1 + 1, 2);
- // assert.strictEqual(1 + 1, 2);
- });
- });
In this Kata, you have to make two predicates, is_odd/1 (I don't need to explain what it does, do I?) and odd_count/2, that returns the number of odd numbers below a certain value without including it.
For example:
odd_count(5,2) ---- 1 and 3
odd_count(6,3) ---- 1,3 and 5
Good luck!
is_odd(X) :- 1 is X mod 2. odd_count(N, R) :- is_odd(N) -> R is (N-1) div 2; R is N div 2.
- is_odd(X) :- 1 is X mod 2.
odd_count(N, R) :- is_odd(N) -> odd_count_recur(N, R); odd_count_recur(N + 1, R).odd_count_recur(0, 0) :- !.odd_count_recur(1, 0) :- !.odd_count_recur(N, R) :- N1 is N - 2, odd_count_recur(N1, R1), R is 1 + R1.- odd_count(N, R) :- is_odd(N) -> R is (N-1) div 2; R is N div 2.
cat = """ ........ ........... ...*@@@%..... .....#@**@#.... . ..-@+--==@%.... ....+@*-===+@# ... .... ....%@-------*@+.... ...@@-=------*@=... .... .. @@----------@@.... ...-@#--------=--@%... .... ....@%------------%@:..... ...#@=-------------@%... .... ....@%-------------=+@+..... ...@@----------------%@. . ...... ....@#-----------------@#.... ...@%----------------=-@%... . ...... ....@%-----------------=-@@.... ...@#--------------------@@... . ...... .... ...@@---------------------*@....................:@+=---------------------@#..... .... .... ..................... ...*@----------------------==@*:::=*#%@@@@@@@@@@@@-------------------------@#.... ..........:.. .... .........::=*#@@@#-.........-@=--------------------------===%@----@%----=@%--------------------------=@+..... ......-#%#-...... .........=%@%-....@*-----------------------------=+@#=--#@-----%@----------------------------@=.... ....-%@*:...... ......-@@+%@------------------------------=-@@---=@==--=*@----------------------------+@-.... .....:%@%:......... ....=@@+-=-----------------------------=#----%+----------------------------------=+@........-%@*...... ...@#-*@+-------------------------------------------------------------------------+@:...-@@#.... . ..+@-=--+@=-----------------------------------------------------------------------=+@:%@*....... ..@+=-----==-----------------------------------------------------------------------#@@:..... ..#%------------------------------------------------------------------------------@@+-+@..... ............. .........:@=---------------------------------------------------------------------------=@@=---=*@.... .......:-====--::.........%*-------------------------------------------------------------=-=##=--------%@-=------*@... ...*#=:. . ..:--+*%@@@@@#@---------------------==@@@@#------------------*=--------------=@@@@@@-----=#*---------=#%.. .. .... ....... .... .....................@**@@@*-=--------------=@@@@@@%----------------*+=--------------%@@@@@@#-----=------------@*......... ....:..... ..... ... . ..=@--==-+@@=------------=*@@@@@@@--------------=+@%=--------------*@@@@@@+=----------------=-@=-+%@@@@%##*+====---:..... ...##--------%+-------------%@@@@@=---------===-=@#==-#@#===---------*@@@@+----------------*@@@@@=............ ...@+-----------------------=-+*=-----------%@@@+=======*+----------------------------=%@@#=---=+@.. ........ ..#@-------------------------------------------@========+*=-------------------------------------=*@.... .:@*-------------------------------------------+%-======%=----------------------------------------%#... ..%@--------------------------------------------=+@=---+@*=-----------------------------------------@-.. ...-@*---------------------------------------------=--===--=------------------------------------------=@... ...@@-------------------------------------------------------------------------------------------------=#%... ..+@+---------------------------------------------------------------------------------------------------@=.. ...@%----------------------------------------------------------------------------------------------------=@... ......... ..+@=-----------------------------------------------------------------------------------------------------#%... ......... ..@#-=-----------------------------------------------------------------------------------------------------@-.. ........ ......... ..*@--------------------------------------------------------------------------------------------------------=@.. ........ ......... ..:@*--------------------------------------------------------------------------------------------------------=%*... ..... .............. ...%@----------------------------------------------------------------------------------------------------------=@... ..... .............. ...-@=-----------------------------------------------------------------------------------------------------------#%.... ........ .............. ...@%-----------------------------------------------------------------------------------------------------------==@-... ........... ............ ..-@--------------------------------------------------------------------------------------------------------------#@.. ........... ............ ..%@@%-=-----------------------------------------------------------------------------------------------------------@-... ........... ..=@***#@+=-------------------------------------------------------------------------------------=++++=-------------=#@... ........... ...@%*****@*=------------------------=--=+*###*=---------------------------------------------#@@@%****%@@%-----------=@-.. ..*@*******@------------------------@@@%#*++++*%@@@+----------------------------------------#=--------==-%@-----------#@... ..@#*******@+-------------------------------------+@@---------------------------------------------------=+@=---------=-@:... ..#@*******#@--------------------------------------==@+--------------------------------------------------%@#------------##... ..:@#***##%@%-=------------------------------------=%@%----------------------------------------+++*#%@@@@@+---------------@... ..*%=+**+=--=--------------------------------+*%@@@@*---------------------------------------------------------------------%+.. ..@-=----------------------------------+%%%@%%#+=--==---------------------------------------------------------------------+@... ...................... ...... ..*%------------------------------------------------------------------------------------------------------------------------@:... .................................... ..@=------------------------------------------------------------------------------------------------------------------------#*... .................................... ..=@-------------------------------------------------------------------------------------------------------------------------=@ .. .................................... . %+--------------------------------------------------------------------------------------------------------------------------@:... .................... .......... ..:@---------------------------------------------------------------------------------------------------------------------------##... ................... ........... ...##---------------------------------------------------------------------------------------------------------------------------=@... .................. ........... ...@=----------------------------------------------------------------------------------------------------------------------------@:.. ...... .-@-----------------------------------------------------------------------------------------------------------------------------%+. ........ ..*@##%@%-----------------------------------------------------------------------------------------------------------------------=+%.... ..... . @#****#@*-----------------------------------------------------------------------------------------------------------------------@.... ........ ..@*******@*----------------------------------------------------------------------------------------------------------------------@:... ......... .=@*******#@+---------------------------------------------------------------------------------------------------------------------%+. . ......... ..%%********@#---------------------------------------------------------------------------------------------------------------------*%. . ......... ..@#*******@@----------------------------------------------------------------------------------------------------------------------+@... ......... ..@%##%%@@@*-=---------------------------------------------------------------------------------------------------------------------=@... ......... ..:@-===-----------------------------------------------------------------------------------------------------------------------------@:.. ...... ..=@---------------------------------------------------------------------------------------------------------------------------------@-.. ..+%---------------------------------------------------------------------------------------------------------------------------------@- . ...*#---------------------------------------------------------------------------------------------------------------------------------@=... ........ ...##---------------------------------------------------------------------------------------------------------------------------------@+.. ....:........ ...#*---------------------------------------------------------------------------------------------------------------------------------@+.. ..@*--*@%.. .. ...#*---------------------------------------------------------------------------------------------------------------------------------@= . .=%----=-#@..... ...##---------------------------------------------------------------------------------------------------------------------------------@-.. .*%=-==%@@@@%...... ...+%---------------------------------------------------------------------------------------------------------------------------------@-.. .=@--%@*****#@+.. . ...=@---------------------------------------------------------------------------------------------------------------------------------@... ..@*#%*******#@@-... ...:@--------------------------------------------------------------------------------------------------------------------------------=@... ..=@@*****#@#---*@+...... ...@=------------------------------------------------------------------------------------------------------------------------------=*@... ...*@****%%------+%@@-.... ..%*=------------------------------------------------------------------------------------------------------------------------------%=... ...+@###@-=---%@#***#@@*....... ..-@-----------------------------------------------------------------------------------------------------------------------------=-@.... ...@@%*--=-@%*****#@#=*@@#-.......@=-----------------------------------------------------------------------------------------------------------------------------*%... ...*@%---*@*****#@-=---@**#@@@@@@@@-----------------------------------------------------------------------------------------------------------------------------@-... .....#@#-#%*****@==---@#*****@+==-@+=--------------------------------------------------------------------------------------------------------------------------*@... ....+@@@****#@----*@******@----+@---------------------------------------------------------------------------------------------------------------------------@.... ....:%@@#*#@=---%%******@+----#@-------------------------------------------------------------------------------------------------------------------------@+.... ......:%@@@@*--+@******%@==---%%-----------------------------------------------------------------------------------------------------------------------%%..... .......=#@@@@@%%##**#@@%**=%@-=-------------------------------------------------------------------------------------------------------------------%#...... ............:-=+*#****=:.=@==-----------------------------------------------------------------------------------------------------------------%#. ... ............@@-=------------------------------------------------------------------------------------------------------------==@=.... ..:@%------------------------------------------------------------------------------------------------------------@%.... .....@@=-------------------------------------------------------------------------------------------------------@@...... .....+@%=-=----------------------------------------------------------------------------------------------=#@*........ .. ..=@@*-----------------------------------------------------------------------------------------=#@@*........... . ....:#@@*=-=--------------------------------------------------------------------------=--=*@@%=......... ..........+@@@#=--=-----------------------------------------------------------------=#@@@%- ..... .....@-+#@@@%#+=---------------------------------------------------=+*%@@@@#+=---@....... ...@-=------=@#%@@@@@%*+==--------------------------==+*#%@@@@@%*=:..@---------%-... ..:@---------@:........::-=+*##%%@@@@@@@@@@@@%%##*+=-::..............@---------#-. . ...@-=-------@.. .......... .. .......... .... ... . ....#*--------@.... ...#%-------*@........ . . .. . . . . . .....@+=-----%*.... ...@%-----+@:... ....*@#+=+@=..... ....-@%#%@@... .......:..... ............. ... ... """ #meow! ^_^
None- cat = """ ........ ...........
- ...*@@@%..... .....#@**@#.... .
- ..-@+--==@%.... ....+@*-===+@# ... ....
- ....%@-------*@+.... ...@@-=------*@=... ....
- .. @@----------@@.... ...-@#--------=--@%... ....
- ....@%------------%@:..... ...#@=-------------@%... ....
- ....@%-------------=+@+..... ...@@----------------%@. . ......
- ....@#-----------------@#.... ...@%----------------=-@%... . ......
- ....@%-----------------=-@@.... ...@#--------------------@@... . ......
- .... ...@@---------------------*@....................:@+=---------------------@#..... .... ....
- ..................... ...*@----------------------==@*:::=*#%@@@@@@@@@@@@-------------------------@#.... ..........:.. ....
- .........::=*#@@@#-.........-@=--------------------------===%@----@%----=@%--------------------------=@+..... ......-#%#-......
- .........=%@%-....@*-----------------------------=+@#=--#@-----%@----------------------------@=.... ....-%@*:......
- ......-@@+%@------------------------------=-@@---=@==--=*@----------------------------+@-.... .....:%@%:.........
- ....=@@+-=-----------------------------=#----%+----------------------------------=+@........-%@*......
- ...@#-*@+-------------------------------------------------------------------------+@:...-@@#.... .
- ..+@-=--+@=-----------------------------------------------------------------------=+@:%@*.......
- ..@+=-----==-----------------------------------------------------------------------#@@:.....
- ..#%------------------------------------------------------------------------------@@+-+@.....
- ............. .........:@=---------------------------------------------------------------------------=@@=---=*@....
- .......:-====--::.........%*-------------------------------------------------------------=-=##=--------%@-=------*@...
- ...*#=:. . ..:--+*%@@@@@#@---------------------==@@@@#------------------*=--------------=@@@@@@-----=#*---------=#%.. .. .... .......
- .... .....................@**@@@*-=--------------=@@@@@@%----------------*+=--------------%@@@@@@#-----=------------@*......... ....:..... .....
- ... . ..=@--==-+@@=------------=*@@@@@@@--------------=+@%=--------------*@@@@@@+=----------------=-@=-+%@@@@%##*+====---:.....
- ...##--------%+-------------%@@@@@=---------===-=@#==-#@#===---------*@@@@+----------------*@@@@@=............
- ...@+-----------------------=-+*=-----------%@@@+=======*+----------------------------=%@@#=---=+@.. ........
- ..#@-------------------------------------------@========+*=-------------------------------------=*@....
- .:@*-------------------------------------------+%-======%=----------------------------------------%#...
- ..%@--------------------------------------------=+@=---+@*=-----------------------------------------@-..
- ...-@*---------------------------------------------=--===--=------------------------------------------=@...
- ...@@-------------------------------------------------------------------------------------------------=#%...
- ..+@+---------------------------------------------------------------------------------------------------@=..
- ...@%----------------------------------------------------------------------------------------------------=@...
- ......... ..+@=-----------------------------------------------------------------------------------------------------#%...
- ......... ..@#-=-----------------------------------------------------------------------------------------------------@-..
- ........ ......... ..*@--------------------------------------------------------------------------------------------------------=@..
- ........ ......... ..:@*--------------------------------------------------------------------------------------------------------=%*...
- ..... .............. ...%@----------------------------------------------------------------------------------------------------------=@...
- ..... .............. ...-@=-----------------------------------------------------------------------------------------------------------#%....
- ........ .............. ...@%-----------------------------------------------------------------------------------------------------------==@-...
- ........... ............ ..-@--------------------------------------------------------------------------------------------------------------#@..
- ........... ............ ..%@@%-=-----------------------------------------------------------------------------------------------------------@-...
- ........... ..=@***#@+=-------------------------------------------------------------------------------------=++++=-------------=#@...
- ........... ...@%*****@*=------------------------=--=+*###*=---------------------------------------------#@@@%****%@@%-----------=@-..
- ..*@*******@------------------------@@@%#*++++*%@@@+----------------------------------------#=--------==-%@-----------#@...
- ..@#*******@+-------------------------------------+@@---------------------------------------------------=+@=---------=-@:...
- ..#@*******#@--------------------------------------==@+--------------------------------------------------%@#------------##...
- ..:@#***##%@%-=------------------------------------=%@%----------------------------------------+++*#%@@@@@+---------------@...
- ..*%=+**+=--=--------------------------------+*%@@@@*---------------------------------------------------------------------%+..
- ..@-=----------------------------------+%%%@%%#+=--==---------------------------------------------------------------------+@...
- ...................... ...... ..*%------------------------------------------------------------------------------------------------------------------------@:...
- .................................... ..@=------------------------------------------------------------------------------------------------------------------------#*...
- .................................... ..=@-------------------------------------------------------------------------------------------------------------------------=@ ..
- .................................... . %+--------------------------------------------------------------------------------------------------------------------------@:...
- .................... .......... ..:@---------------------------------------------------------------------------------------------------------------------------##...
- ................... ........... ...##---------------------------------------------------------------------------------------------------------------------------=@...
- .................. ........... ...@=----------------------------------------------------------------------------------------------------------------------------@:..
- ...... .-@-----------------------------------------------------------------------------------------------------------------------------%+.
- ........ ..*@##%@%-----------------------------------------------------------------------------------------------------------------------=+%....
- ..... . @#****#@*-----------------------------------------------------------------------------------------------------------------------@....
- ........ ..@*******@*----------------------------------------------------------------------------------------------------------------------@:...
- ......... .=@*******#@+---------------------------------------------------------------------------------------------------------------------%+. .
- ......... ..%%********@#---------------------------------------------------------------------------------------------------------------------*%. .
- ......... ..@#*******@@----------------------------------------------------------------------------------------------------------------------+@...
- ......... ..@%##%%@@@*-=---------------------------------------------------------------------------------------------------------------------=@...
- ......... ..:@-===-----------------------------------------------------------------------------------------------------------------------------@:..
- ...... ..=@---------------------------------------------------------------------------------------------------------------------------------@-..
- ..+%---------------------------------------------------------------------------------------------------------------------------------@- .
- ...*#---------------------------------------------------------------------------------------------------------------------------------@=...
- ........ ...##---------------------------------------------------------------------------------------------------------------------------------@+..
- ....:........ ...#*---------------------------------------------------------------------------------------------------------------------------------@+..
- ..@*--*@%.. .. ...#*---------------------------------------------------------------------------------------------------------------------------------@= .
- .=%----=-#@..... ...##---------------------------------------------------------------------------------------------------------------------------------@-..
- .*%=-==%@@@@%...... ...+%---------------------------------------------------------------------------------------------------------------------------------@-..
- .=@--%@*****#@+.. . ...=@---------------------------------------------------------------------------------------------------------------------------------@...
- ..@*#%*******#@@-... ...:@--------------------------------------------------------------------------------------------------------------------------------=@...
- ..=@@*****#@#---*@+...... ...@=------------------------------------------------------------------------------------------------------------------------------=*@...
- ...*@****%%------+%@@-.... ..%*=------------------------------------------------------------------------------------------------------------------------------%=...
- ...+@###@-=---%@#***#@@*....... ..-@-----------------------------------------------------------------------------------------------------------------------------=-@....
- ...@@%*--=-@%*****#@#=*@@#-.......@=-----------------------------------------------------------------------------------------------------------------------------*%...
- ...*@%---*@*****#@-=---@**#@@@@@@@@-----------------------------------------------------------------------------------------------------------------------------@-...
- .....#@#-#%*****@==---@#*****@+==-@+=--------------------------------------------------------------------------------------------------------------------------*@...
- ....+@@@****#@----*@******@----+@---------------------------------------------------------------------------------------------------------------------------@....
- ....:%@@#*#@=---%%******@+----#@-------------------------------------------------------------------------------------------------------------------------@+....
- ......:%@@@@*--+@******%@==---%%-----------------------------------------------------------------------------------------------------------------------%%.....
- .......=#@@@@@%%##**#@@%**=%@-=-------------------------------------------------------------------------------------------------------------------%#......
- ............:-=+*#****=:.=@==-----------------------------------------------------------------------------------------------------------------%#. ...
- ............@@-=------------------------------------------------------------------------------------------------------------==@=....
- ..:@%------------------------------------------------------------------------------------------------------------@%....
- .....@@=-------------------------------------------------------------------------------------------------------@@......
- .....+@%=-=----------------------------------------------------------------------------------------------=#@*........
- .. ..=@@*-----------------------------------------------------------------------------------------=#@@*...........
- . ....:#@@*=-=--------------------------------------------------------------------------=--=*@@%=.........
- ..........+@@@#=--=-----------------------------------------------------------------=#@@@%- .....
- .....@-+#@@@%#+=---------------------------------------------------=+*%@@@@#+=---@.......
- ...@-=------=@#%@@@@@%*+==--------------------------==+*#%@@@@@%*=:..@---------%-...
- ..:@---------@:........::-=+*##%%@@@@@@@@@@@@%%##*+=-::..............@---------#-. .
- ...@-=-------@.. .......... .. .......... .... ... . ....#*--------@....
- ...#%-------*@........ . . .. . . . . . .....@+=-----%*....
- ...@%-----+@:... ....*@#+=+@=.....
- ....-@%#%@@... .......:.....
- ............. ... ... """
- #meow! ^_^