Start a new Kumite
AllAgda (Beta)BF (Beta)CCFML (Beta)ClojureCOBOL (Beta)CoffeeScriptCommonLisp (Beta)CoqC++CrystalC#D (Beta)DartElixirElm (Beta)Erlang (Beta)Factor (Beta)Forth (Beta)Fortran (Beta)F#GoGroovyHaskellHaxe (Beta)Idris (Beta)JavaJavaScriptJulia (Beta)Kotlinλ Calculus (Beta)LeanLuaNASMNim (Beta)Objective-C (Beta)OCaml (Beta)Pascal (Beta)Perl (Beta)PHPPowerShell (Beta)Prolog (Beta)PureScript (Beta)PythonR (Beta)RacketRaku (Beta)Reason (Beta)RISC-V (Beta)RubyRustScalaShellSolidity (Beta)SQLSwiftTypeScriptVB (Beta)
Show only mine

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.

Ad
Ad
Code
Diff
  • // # 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;
Fundamentals
Strings
Code
Diff
  • reverse_string = lambda n: n[::-1]
    • reverse_string = lambda n: ''.join(reversed(n))
    • reverse_string = lambda n: n[::-1]
Fundamentals

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!

Code
Diff
  • 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.
Code
Diff
  • cat = """                                                                           ........                                      ...........                                                            
                                                                                       ...*@@@%.....                                .....#@**@#....                                                          .
                                                                                      ..-@+--==@%....                              ....+@*-===+@# ...                                                     ....
                                                                                   ....%@-------*@+....                            ...@@-=------*@=...                                                    ....
                                                                                   .. @@----------@@....                         ...-@#--------=--@%...                                                   ....
                                                                                 ....@%------------%@:.....                     ...#@=-------------@%...                                                  ....
                                                                                ....@%-------------=+@+.....                   ...@@----------------%@.  .                                              ......
                                                                               ....@#-----------------@#....                  ...@%----------------=-@%...  .                                           ......
                                                                              ....@%-----------------=-@@....                ...@#--------------------@@... .                                           ......
                                                     ....                     ...@@---------------------*@....................:@+=---------------------@#.....                          ....            ....  
                                                   .....................     ...*@----------------------==@*:::=*#%@@@@@@@@@@@@-------------------------@#....                 ..........:..            ....  
                                                   .........::=*#@@@#-.........-@=--------------------------===%@----@%----=@%--------------------------=@+.....           ......-#%#-......                  
                                                             .........=%@%-....@*-----------------------------=+@#=--#@-----%@----------------------------@=....        ....-%@*:......                       
                                                                    ......-@@+%@------------------------------=-@@---=@==--=*@----------------------------+@-....  .....:%@%:.........                        
                                                                         ....=@@+-=-----------------------------=#----%+----------------------------------=+@........-%@*......                               
                                                                          ...@#-*@+-------------------------------------------------------------------------+@:...-@@#....   .                                
                                                                          ..+@-=--+@=-----------------------------------------------------------------------=+@:%@*.......                                    
                                                                          ..@+=-----==-----------------------------------------------------------------------#@@:.....                                        
                                                                         ..#%------------------------------------------------------------------------------@@+-+@.....                                        
                                                   ............. .........:@=---------------------------------------------------------------------------=@@=---=*@....                                        
                                                .......:-====--::.........%*-------------------------------------------------------------=-=##=--------%@-=------*@...                                        
                                               ...*#=:.  .  ..:--+*%@@@@@#@---------------------==@@@@#------------------*=--------------=@@@@@@-----=#*---------=#%..      .. ....  .......                  
                                               .... .....................@**@@@*-=--------------=@@@@@@%----------------*+=--------------%@@@@@@#-----=------------@*......... ....:..... .....               
                                               ...  .                 ..=@--==-+@@=------------=*@@@@@@@--------------=+@%=--------------*@@@@@@+=----------------=-@=-+%@@@@%##*+====---:.....               
                                                                     ...##--------%+-------------%@@@@@=---------===-=@#==-#@#===---------*@@@@+----------------*@@@@@=............                           
                                                                     ...@+-----------------------=-+*=-----------%@@@+=======*+----------------------------=%@@#=---=+@.. ........                            
                                                                     ..#@-------------------------------------------@========+*=-------------------------------------=*@....                                  
                                                                     .:@*-------------------------------------------+%-======%=----------------------------------------%#...                                  
                                                                    ..%@--------------------------------------------=+@=---+@*=-----------------------------------------@-..                                  
                                                                  ...-@*---------------------------------------------=--===--=------------------------------------------=@...                                 
                                                                  ...@@-------------------------------------------------------------------------------------------------=#%...                                
                                                                  ..+@+---------------------------------------------------------------------------------------------------@=..                                
                                                                 ...@%----------------------------------------------------------------------------------------------------=@...                               
                                           .........             ..+@=-----------------------------------------------------------------------------------------------------#%...                              
                                           .........             ..@#-=-----------------------------------------------------------------------------------------------------@-..                              
    ........                               .........            ..*@--------------------------------------------------------------------------------------------------------=@..                              
    ........                               .........           ..:@*--------------------------------------------------------------------------------------------------------=%*...                            
    .....                             ..............          ...%@----------------------------------------------------------------------------------------------------------=@...                            
    .....                           ..............           ...-@=-----------------------------------------------------------------------------------------------------------#%....                          
    ........                        ..............           ...@%-----------------------------------------------------------------------------------------------------------==@-...                          
    ...........                     ............             ..-@--------------------------------------------------------------------------------------------------------------#@..                           
    ...........                     ............             ..%@@%-=-----------------------------------------------------------------------------------------------------------@-...                         
    ...........                                             ..=@***#@+=-------------------------------------------------------------------------------------=++++=-------------=#@...                         
    ...........                                            ...@%*****@*=------------------------=--=+*###*=---------------------------------------------#@@@%****%@@%-----------=@-..                         
                                                           ..*@*******@------------------------@@@%#*++++*%@@@+----------------------------------------#=--------==-%@-----------#@...                        
                                                           ..@#*******@+-------------------------------------+@@---------------------------------------------------=+@=---------=-@:...                       
                                                          ..#@*******#@--------------------------------------==@+--------------------------------------------------%@#------------##...                       
                                                         ..:@#***##%@%-=------------------------------------=%@%----------------------------------------+++*#%@@@@@+---------------@...                       
                                                         ..*%=+**+=--=--------------------------------+*%@@@@*---------------------------------------------------------------------%+..                       
                                                         ..@-=----------------------------------+%%%@%%#+=--==---------------------------------------------------------------------+@...                      
    ......................      ......                  ..*%------------------------------------------------------------------------------------------------------------------------@:...                     
    ....................................                ..@=------------------------------------------------------------------------------------------------------------------------#*...                     
    ....................................               ..=@-------------------------------------------------------------------------------------------------------------------------=@ ..                     
    ....................................               . %+--------------------------------------------------------------------------------------------------------------------------@:...                    
    ....................    ..........                ..:@---------------------------------------------------------------------------------------------------------------------------##...                    
    ...................    ...........               ...##---------------------------------------------------------------------------------------------------------------------------=@...                    
    ..................     ...........               ...@=----------------------------------------------------------------------------------------------------------------------------@:..                    
                            ......                    .-@-----------------------------------------------------------------------------------------------------------------------------%+.                     
                          ........                   ..*@##%@%-----------------------------------------------------------------------------------------------------------------------=+%....                  
                          .....                      . @#****#@*-----------------------------------------------------------------------------------------------------------------------@....                  
                          ........                   ..@*******@*----------------------------------------------------------------------------------------------------------------------@:...                  
                          .........                  .=@*******#@+---------------------------------------------------------------------------------------------------------------------%+. .                  
                          .........                 ..%%********@#---------------------------------------------------------------------------------------------------------------------*%. .                  
                          .........                 ..@#*******@@----------------------------------------------------------------------------------------------------------------------+@...                  
                          .........                 ..@%##%%@@@*-=---------------------------------------------------------------------------------------------------------------------=@...                  
                          .........                ..:@-===-----------------------------------------------------------------------------------------------------------------------------@:..                  
                            ......                 ..=@---------------------------------------------------------------------------------------------------------------------------------@-..                  
                                                   ..+%---------------------------------------------------------------------------------------------------------------------------------@- .                  
                                                  ...*#---------------------------------------------------------------------------------------------------------------------------------@=...                 
                    ........                      ...##---------------------------------------------------------------------------------------------------------------------------------@+..                  
                  ....:........                   ...#*---------------------------------------------------------------------------------------------------------------------------------@+..                  
                  ..@*--*@%.. ..                  ...#*---------------------------------------------------------------------------------------------------------------------------------@= .                  
                  .=%----=-#@.....                ...##---------------------------------------------------------------------------------------------------------------------------------@-..                  
                  .*%=-==%@@@@%......             ...+%---------------------------------------------------------------------------------------------------------------------------------@-..                  
                  .=@--%@*****#@+.. .             ...=@---------------------------------------------------------------------------------------------------------------------------------@...                  
                  ..@*#%*******#@@-...            ...:@--------------------------------------------------------------------------------------------------------------------------------=@...                  
                  ..=@@*****#@#---*@+......        ...@=------------------------------------------------------------------------------------------------------------------------------=*@...                  
                  ...*@****%%------+%@@-....        ..%*=------------------------------------------------------------------------------------------------------------------------------%=...                  
                   ...+@###@-=---%@#***#@@*.......  ..-@-----------------------------------------------------------------------------------------------------------------------------=-@....                  
                     ...@@%*--=-@%*****#@#=*@@#-.......@=-----------------------------------------------------------------------------------------------------------------------------*%...                   
                      ...*@%---*@*****#@-=---@**#@@@@@@@@-----------------------------------------------------------------------------------------------------------------------------@-...                   
                      .....#@#-#%*****@==---@#*****@+==-@+=--------------------------------------------------------------------------------------------------------------------------*@...                    
                         ....+@@@****#@----*@******@----+@---------------------------------------------------------------------------------------------------------------------------@....                    
                           ....:%@@#*#@=---%%******@+----#@-------------------------------------------------------------------------------------------------------------------------@+....                    
                            ......:%@@@@*--+@******%@==---%%-----------------------------------------------------------------------------------------------------------------------%%.....                    
                                .......=#@@@@@%%##**#@@%**=%@-=-------------------------------------------------------------------------------------------------------------------%#......                    
                                   ............:-=+*#****=:.=@==-----------------------------------------------------------------------------------------------------------------%#. ...                      
                                                  ............@@-=------------------------------------------------------------------------------------------------------------==@=....                        
                                                             ..:@%------------------------------------------------------------------------------------------------------------@%....                          
                                                             .....@@=-------------------------------------------------------------------------------------------------------@@......                          
                                                               .....+@%=-=----------------------------------------------------------------------------------------------=#@*........                          
                                                                  .. ..=@@*-----------------------------------------------------------------------------------------=#@@*...........                          
                                                                    . ....:#@@*=-=--------------------------------------------------------------------------=--=*@@%=.........                                
                                                                     ..........+@@@#=--=-----------------------------------------------------------------=#@@@%- .....                                        
                                                                             .....@-+#@@@%#+=---------------------------------------------------=+*%@@@@#+=---@.......                                        
                                                                               ...@-=------=@#%@@@@@%*+==--------------------------==+*#%@@@@@%*=:..@---------%-...                                           
                                                                               ..:@---------@:........::-=+*##%%@@@@@@@@@@@@%%##*+=-::..............@---------#-. .                                           
                                                                               ...@-=-------@..    ..........  ..  ..........  ....  ...    .   ....#*--------@....                                           
                                                                               ...#%-------*@........      .    .  .. .     .    .    .     .   .....@+=-----%*....                                           
                                                                                ...@%-----+@:...                                                  ....*@#+=+@=.....                                           
                                                                                ....-@%#%@@...                                                     .......:.....                                              
                                                                                 .............                                                           ... ...  """                                            
                                                                                                                                                                                          
        #meow! ^_^
                                                                                                                                                                                                              
                                                                                                                                                                                                              
                                                                                                                                                                                                              
                                                                                                                                                                                                              
                                                                                                                                                                                                              
                                                                                                                                                                                                              
                                                                                                                                                                                                              
    
    
    
    
    • None
    • cat = """ ........ ...........
    • ...*@@@%..... .....#@**@#.... .
    • ..-@+--==@%.... ....+@*-===+@# ... ....
    • ....%@-------*@+.... ...@@-=------*@=... ....
    • .. @@----------@@.... ...-@#--------=--@%... ....
    • ....@%------------%@:..... ...#@=-------------@%... ....
    • ....@%-------------=+@+..... ...@@----------------%@. . ......
    • ....@#-----------------@#.... ...@%----------------=-@%... . ......
    • ....@%-----------------=-@@.... ...@#--------------------@@... . ......
    • .... ...@@---------------------*@....................:@+=---------------------@#..... .... ....
    • ..................... ...*@----------------------==@*:::=*#%@@@@@@@@@@@@-------------------------@#.... ..........:.. ....
    • .........::=*#@@@#-.........-@=--------------------------===%@----@%----=@%--------------------------=@+..... ......-#%#-......
    • .........=%@%-....@*-----------------------------=+@#=--#@-----%@----------------------------@=.... ....-%@*:......
    • ......-@@+%@------------------------------=-@@---=@==--=*@----------------------------+@-.... .....:%@%:.........
    • ....=@@+-=-----------------------------=#----%+----------------------------------=+@........-%@*......
    • ...@#-*@+-------------------------------------------------------------------------+@:...-@@#.... .
    • ..+@-=--+@=-----------------------------------------------------------------------=+@:%@*.......
    • ..@+=-----==-----------------------------------------------------------------------#@@:.....
    • ..#%------------------------------------------------------------------------------@@+-+@.....
    • ............. .........:@=---------------------------------------------------------------------------=@@=---=*@....
    • .......:-====--::.........%*-------------------------------------------------------------=-=##=--------%@-=------*@...
    • ...*#=:. . ..:--+*%@@@@@#@---------------------==@@@@#------------------*=--------------=@@@@@@-----=#*---------=#%.. .. .... .......
    • .... .....................@**@@@*-=--------------=@@@@@@%----------------*+=--------------%@@@@@@#-----=------------@*......... ....:..... .....
    • ... . ..=@--==-+@@=------------=*@@@@@@@--------------=+@%=--------------*@@@@@@+=----------------=-@=-+%@@@@%##*+====---:.....
    • ...##--------%+-------------%@@@@@=---------===-=@#==-#@#===---------*@@@@+----------------*@@@@@=............
    • ...@+-----------------------=-+*=-----------%@@@+=======*+----------------------------=%@@#=---=+@.. ........
    • ..#@-------------------------------------------@========+*=-------------------------------------=*@....
    • .:@*-------------------------------------------+%-======%=----------------------------------------%#...
    • ..%@--------------------------------------------=+@=---+@*=-----------------------------------------@-..
    • ...-@*---------------------------------------------=--===--=------------------------------------------=@...
    • ...@@-------------------------------------------------------------------------------------------------=#%...
    • ..+@+---------------------------------------------------------------------------------------------------@=..
    • ...@%----------------------------------------------------------------------------------------------------=@...
    • ......... ..+@=-----------------------------------------------------------------------------------------------------#%...
    • ......... ..@#-=-----------------------------------------------------------------------------------------------------@-..
    • ........ ......... ..*@--------------------------------------------------------------------------------------------------------=@..
    • ........ ......... ..:@*--------------------------------------------------------------------------------------------------------=%*...
    • ..... .............. ...%@----------------------------------------------------------------------------------------------------------=@...
    • ..... .............. ...-@=-----------------------------------------------------------------------------------------------------------#%....
    • ........ .............. ...@%-----------------------------------------------------------------------------------------------------------==@-...
    • ........... ............ ..-@--------------------------------------------------------------------------------------------------------------#@..
    • ........... ............ ..%@@%-=-----------------------------------------------------------------------------------------------------------@-...
    • ........... ..=@***#@+=-------------------------------------------------------------------------------------=++++=-------------=#@...
    • ........... ...@%*****@*=------------------------=--=+*###*=---------------------------------------------#@@@%****%@@%-----------=@-..
    • ..*@*******@------------------------@@@%#*++++*%@@@+----------------------------------------#=--------==-%@-----------#@...
    • ..@#*******@+-------------------------------------+@@---------------------------------------------------=+@=---------=-@:...
    • ..#@*******#@--------------------------------------==@+--------------------------------------------------%@#------------##...
    • ..:@#***##%@%-=------------------------------------=%@%----------------------------------------+++*#%@@@@@+---------------@...
    • ..*%=+**+=--=--------------------------------+*%@@@@*---------------------------------------------------------------------%+..
    • ..@-=----------------------------------+%%%@%%#+=--==---------------------------------------------------------------------+@...
    • ...................... ...... ..*%------------------------------------------------------------------------------------------------------------------------@:...
    • .................................... ..@=------------------------------------------------------------------------------------------------------------------------#*...
    • .................................... ..=@-------------------------------------------------------------------------------------------------------------------------=@ ..
    • .................................... . %+--------------------------------------------------------------------------------------------------------------------------@:...
    • .................... .......... ..:@---------------------------------------------------------------------------------------------------------------------------##...
    • ................... ........... ...##---------------------------------------------------------------------------------------------------------------------------=@...
    • .................. ........... ...@=----------------------------------------------------------------------------------------------------------------------------@:..
    • ...... .-@-----------------------------------------------------------------------------------------------------------------------------%+.
    • ........ ..*@##%@%-----------------------------------------------------------------------------------------------------------------------=+%....
    • ..... . @#****#@*-----------------------------------------------------------------------------------------------------------------------@....
    • ........ ..@*******@*----------------------------------------------------------------------------------------------------------------------@:...
    • ......... .=@*******#@+---------------------------------------------------------------------------------------------------------------------%+. .
    • ......... ..%%********@#---------------------------------------------------------------------------------------------------------------------*%. .
    • ......... ..@#*******@@----------------------------------------------------------------------------------------------------------------------+@...
    • ......... ..@%##%%@@@*-=---------------------------------------------------------------------------------------------------------------------=@...
    • ......... ..:@-===-----------------------------------------------------------------------------------------------------------------------------@:..
    • ...... ..=@---------------------------------------------------------------------------------------------------------------------------------@-..
    • ..+%---------------------------------------------------------------------------------------------------------------------------------@- .
    • ...*#---------------------------------------------------------------------------------------------------------------------------------@=...
    • ........ ...##---------------------------------------------------------------------------------------------------------------------------------@+..
    • ....:........ ...#*---------------------------------------------------------------------------------------------------------------------------------@+..
    • ..@*--*@%.. .. ...#*---------------------------------------------------------------------------------------------------------------------------------@= .
    • .=%----=-#@..... ...##---------------------------------------------------------------------------------------------------------------------------------@-..
    • .*%=-==%@@@@%...... ...+%---------------------------------------------------------------------------------------------------------------------------------@-..
    • .=@--%@*****#@+.. . ...=@---------------------------------------------------------------------------------------------------------------------------------@...
    • ..@*#%*******#@@-... ...:@--------------------------------------------------------------------------------------------------------------------------------=@...
    • ..=@@*****#@#---*@+...... ...@=------------------------------------------------------------------------------------------------------------------------------=*@...
    • ...*@****%%------+%@@-.... ..%*=------------------------------------------------------------------------------------------------------------------------------%=...
    • ...+@###@-=---%@#***#@@*....... ..-@-----------------------------------------------------------------------------------------------------------------------------=-@....
    • ...@@%*--=-@%*****#@#=*@@#-.......@=-----------------------------------------------------------------------------------------------------------------------------*%...
    • ...*@%---*@*****#@-=---@**#@@@@@@@@-----------------------------------------------------------------------------------------------------------------------------@-...
    • .....#@#-#%*****@==---@#*****@+==-@+=--------------------------------------------------------------------------------------------------------------------------*@...
    • ....+@@@****#@----*@******@----+@---------------------------------------------------------------------------------------------------------------------------@....
    • ....:%@@#*#@=---%%******@+----#@-------------------------------------------------------------------------------------------------------------------------@+....
    • ......:%@@@@*--+@******%@==---%%-----------------------------------------------------------------------------------------------------------------------%%.....
    • .......=#@@@@@%%##**#@@%**=%@-=-------------------------------------------------------------------------------------------------------------------%#......
    • ............:-=+*#****=:.=@==-----------------------------------------------------------------------------------------------------------------%#. ...
    • ............@@-=------------------------------------------------------------------------------------------------------------==@=....
    • ..:@%------------------------------------------------------------------------------------------------------------@%....
    • .....@@=-------------------------------------------------------------------------------------------------------@@......
    • .....+@%=-=----------------------------------------------------------------------------------------------=#@*........
    • .. ..=@@*-----------------------------------------------------------------------------------------=#@@*...........
    • . ....:#@@*=-=--------------------------------------------------------------------------=--=*@@%=.........
    • ..........+@@@#=--=-----------------------------------------------------------------=#@@@%- .....
    • .....@-+#@@@%#+=---------------------------------------------------=+*%@@@@#+=---@.......
    • ...@-=------=@#%@@@@@%*+==--------------------------==+*#%@@@@@%*=:..@---------%-...
    • ..:@---------@:........::-=+*##%%@@@@@@@@@@@@%%##*+=-::..............@---------#-. .
    • ...@-=-------@.. .......... .. .......... .... ... . ....#*--------@....
    • ...#%-------*@........ . . .. . . . . . .....@+=-----%*....
    • ...@%-----+@:... ....*@#+=+@=.....
    • ....-@%#%@@... .......:.....
    • ............. ... ... """
    • #meow! ^_^