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.
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! ^_^
func gradeCalc(_ score: Int) -> String { (0...100~=score) ? String(Array("FFFFFFDCBAA")[score/10]) : "Not a grade" }
- func gradeCalc(_ score: Int) -> String {
(0...100~=score) ? ["F","F","F","F","F","F","D","C","B","A","A"][score / 10] : "Not a grade"- (0...100~=score) ? String(Array("FFFFFFDCBAA")[score/10]) : "Not a grade"
- }
extension String { func insert(_ value: String, interval: Int) -> String { guard interval > 0 && interval < count else { return self } let chars = Array(self) var result = "" var i = 0 while i+interval<count { result.append(String(chars[i..<min(count,i+interval)])+value) i += interval } result.append(String(chars[i..<min(count,i+interval)])) return result } }
- extension String {
- func insert(_ value: String, interval: Int) -> String {
- guard interval > 0 && interval < count else { return self }
- let chars = Array(self)
- var result = ""
- var i = 0
- while i+interval<count {
result.append(String(chars[i..<min(count,i+interval)]))result.append(value)- result.append(String(chars[i..<min(count,i+interval)])+value)
- i += interval
- }
- result.append(String(chars[i..<min(count,i+interval)]))
- return result
- }
- }