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
  • convert_binary_decimal = lambda n: int(f"{n}", 2)
    • convert_binary_decimal = lambda n: int(str(n), 2)
    • convert_binary_decimal = lambda n: int(f"{n}", 2)
Algorithms
Fundamentals
Code
Diff
  • def collatz(n):
        attempts = 0
        while n != 1:
            if n % 2:
                n = (3*n+1) // 2
                attempts += 2
            else:
                n //= 2
                attempts += 1
        return attempts
    • def collatz(n):
    • attempts = 0
    • while n != 1:
    • if n % 2 == 0:
    • n /= 2
    • attempts += 1
    • if n % 2:
    • n = (3*n+1) // 2
    • attempts += 2
    • else:
    • n = (3*n) + 1
    • n //= 2
    • attempts += 1
    • return attempts
Code
Diff
  • """ONLY HERE TO PASS THE TESTS"""
    """THE REST OF THE PROGRAM RUNS WITHOUT THESE"""
    
    #
    #
    #
    
    def celsius_to_fahrenheit(fahrenheit):
        """Converts fahrenheit to celsius."""
        return (fahrenheit - 32) * 5 / 9
    
    
    def fahrenheit_to_celsius(celsius):
        """Converts celsius to fahrenheit."""
        return (celsius * 9 / 5) + 32
    
    """ONLY HERE TO PASS THE TESTS"""
    """THE REST OF THE PROGRAM RUNS WITHOUT THESE"""
    
    #
    #
    #
    
    error_message = lambda text: f"\033[31m{text}\033[0m"
    highlight_mode = lambda text: f"\033[36m{text}\033[0m"
    
    if __name__ == "__main__":
        while True:
            choice = input("Would you like to convert (c)elsius, (f)ahrenheit or (q)uit:\n>")
            try:
                {
                    "c": lambda x: print(highlight_mode(f"{((x * 9 / 5) + 32):.1f}° Fahrenheit")),
                    "f": lambda x: print(highlight_mode(f"{((x - 32) * 5 / 9):.1f}° Celsius"))
                }[choice](int(input(f"""{highlight_mode(f'Converting {"Celsius to Fahrenheit" if choice == "c" else "Fahrenheit to Celsius"}')}\nEnter temperature in {'Celcius' if choice == 'c' else 'Fahrenheit'}:\n>""")))
            except:
                if choice == "q": break
                print(error_message("Invalid input"))
    
        print("Goodbye!")
    • import sys
    • """ONLY HERE TO PASS THE TESTS"""
    • """THE REST OF THE PROGRAM RUNS WITHOUT THESE"""
    • #
    • #
    • #
    • def celsius_to_fahrenheit(fahrenheit):
    • """Converts fahrenheit to celsius."""
    • return (fahrenheit - 32) * 5 / 9
    • def fahrenheit_to_celsius(celsius):
    • """Converts celsius to fahrenheit."""
    • return (celsius * 9 / 5) + 32
    • """ONLY HERE TO PASS THE TESTS"""
    • """THE REST OF THE PROGRAM RUNS WITHOUT THESE"""
    • def get_temperature(metrics: str) -> int:
    • """Gets and returns the temperature.
    • #
    • #
    • #
    • :param metrics: will be either 'celsius' or 'fahrenheit'
    • :return: the temperature the user inputs.
    • """
    • if metrics == 'celsius':
    • print(highlight_mode(f'Converting Celsius to Fahrenheit'))
    • else:
    • print(highlight_mode(f'Converting Fahrenheit to Celsius'))
    • error_message = lambda text: f"\033[31m{text}\033[0m"
    • highlight_mode = lambda text: f"\033[36m{text}\033[0m"
    • if __name__ == "__main__":
    • while True:
    • # validate user input
    • user_input = input(f'Enter temperature in {metrics}:
    • > ')
    • # if user_input is not valid:
    • if not user_input.isdigit():
    • print(error_message('Invalid input'))
    • # continue asking for input
    • continue
    • else:
    • break
    • return int(user_input)
    • choice = input("Would you like to convert (c)elsius, (f)ahrenheit or (q)uit:
    • >")
    • try:
    • {
    • "c": lambda x: print(highlight_mode(f"{((x * 9 / 5) + 32):.1f}° Fahrenheit")),
    • "f": lambda x: print(highlight_mode(f"{((x - 32) * 5 / 9):.1f}° Celsius"))
    • }[choice](int(input(f"""{highlight_mode(f'Converting {"Celsius to Fahrenheit" if choice == "c" else "Fahrenheit to Celsius"}')}\nEnter temperature in {'Celcius' if choice == 'c' else 'Fahrenheit'}:\n>""")))
    • except:
    • if choice == "q": break
    • print(error_message("Invalid input"))
    • def get_metrics() -> str:
    • """Returns User's selects of conversion; either celsius or fahrenheit."""
    • while True:
    • user_input = input('Would you like to convert (c)elsius, (f)ahrenheit, or (q)uit:\n> ')
    • # if invalid, continue asking for input
    • if user_input not in 'cfq':
    • print(error_message('Invalid input'))
    • # continue asking for input
    • continue
    • else:
    • break
    • # If user selects 'q' for quit:
    • if user_input == 'q':
    • print('Goodbye!')
    • sys.exit()
    • # If user selects 'c' for celsius:
    • elif user_input == 'c':
    • return 'celsius'
    • # If user selects 'f' for fahrenheit
    • return 'fahrenheit'
    • def convert_temperature(temperature: int, metrics: str) -> None:
    • """Prints temperature in either celsius or fahrenheit.
    • :param temperature: the temperature that will be converted
    • :param metrics: will be either 'celsius' or 'fahrenheit'
    • :return: the temperature converted in either 'celsius' or 'fahrenheit'
    • """
    • if metrics == 'celsius':
    • print(highlight_mode(f'{celsius_to_fahrenheit(temperature)}° celsius'))
    • else:
    • print(highlight_mode(f'{fahrenheit_to_celsius(temperature)}° fahrenheit'))
    • def highlight_mode(text: str) -> str:
    • """teal color font to highlight output."""
    • return f'\033[36m{text}\033[0m'
    • def error_message(text: str) -> str:
    • """red color font to highlight error messages."""
    • return f'\033[31m{text}\033[0m'
    • def main():
    • """Main program."""
    • while True:
    • # get the metrics
    • metrics = get_metrics()
    • # get the temperature
    • temperature = get_temperature(metrics)
    • # convert temperature
    • convert_temperature(temperature, metrics)
    • if __name__ == '__main__':
    • main()
    • print("Goodbye!")
Code
Diff
  • #include <stdlib.h>
    
    char *fanis(char* r, int k) {
        char* w = malloc(0);
        for (int i = 0; r[i]; w[i] = k + r[i], i++);
        return w;
    }
    • int *fanis(char *r,int k) {
    • char *w = malloc(0);
    • for (int i = 0; r[i]; w[i++] = k + r[i]);
    • #include <stdlib.h>
    • char *fanis(char* r, int k) {
    • char* w = malloc(0);
    • for (int i = 0; r[i]; w[i] = k + r[i], i++);
    • return w;
    • }
Fundamentals
Code
Diff
  • exec(bytes('敨汬彯敭獳条⁥‽慬扭慤㨠✠效汬潗汲Ⅴ‧', 'u16')[2:])
    """
    
     ^&&7                                                          Y@G.   
       !B#Y^                                                    ^5#G^     
         .7PBP7:                                           .^?PBP!.       
             ~@@!                                   .:~7Y5PPY!.           
            ^&&^     .^?5P555JJJ?7777!!!7777?JJY5555YJ7~:.                
           Y@5  :!J5GPJ!:   ....^^^^^^~^^^^^:...                          
         :&@#JPP5?~.                                                      
        .BBY!:.             .........                                     
                          ...............   .........                     
                        ................................                  
                       ..................................                 
                  ..^~7????7~~^::.........::^^~!!77???7!~^:.              
              :!?YPBGGBBB###&&&##GPYYJJYYY5PGGGPP55YYY5PGGPYJ7.           
             :JY5&#7^::::::^~!!7YB&##BBBBGP?~^::........~5BP5P:           
              ~JG&!.......:^^^^:.^#&#B#BGGY..::::........^GP5J            
              .7G&~......:^^::::.^&&BP5PBG5:::.:.  .::::.:5PP~            
              .^5#Y.......::::::.J@#Y~^~5BG7...:.  .:::::~YPY~.           
              .:7B#^.........::.~&&G~^^~!PBP~...  .::::::!PP7~.           
              ..:JBG~:........:?&@B7^^^~~7GBG?^...::::^7YPP?~!.           
              .:.:!PBGPYJJJJ5B&@&5!^^^^^~~!JGBGP5YYYY5PGPY!~!~            
               ::..:^7YPGBBBGPJ!^^^^^^^^~~~~~7?JY5555YJ7!~~~!.            
                :::....::!^:::::::^^^^^^~~~~~~~~!!^~~~~~!!!!:             
                 :^::::::~^~77!~^^^^^~~~~~~!!7?J7:.^!!!!!!!:              
                  :^^::::::::^7?J7....:~....~?~..:~!!!!!!!.               
                   .^~^^^^^^^::::.     .     .:^!!!!!!!!:                 
                     .^~~~^^~^~^^^:.  ..   .~!!!!!!!!~:                   
                       .:^~!~~~~~~~~~~~!~~!!!!!!!!~^.                     
                           .:^~!!!!!!!!!!!!!!!~^:.                        
                                ...:::::::...                             
                                                                          
    """
    • def hello_message():
    • return 'Hello World!'
    • exec(bytes('敨汬彯敭獳条⁥‽慬扭慤㨠✠效汬潗汲Ⅴ‧', 'u16')[2:])
    • """
    • ^&&7 Y@G.
    • !B#Y^ ^5#G^
    • .7PBP7: .^?PBP!.
    • ~@@! .:~7Y5PPY!.
    • ^&&^ .^?5P555JJJ?7777!!!7777?JJY5555YJ7~:.
    • Y@5 :!J5GPJ!: ....^^^^^^~^^^^^:...
    • :&@#JPP5?~.
    • .BBY!:. .........
    • ............... .........
    • ................................
    • ..................................
    • ..^~7????7~~^::.........::^^~!!77???7!~^:.
    • :!?YPBGGBBB###&&&##GPYYJJYYY5PGGGPP55YYY5PGGPYJ7.
    • :JY5&#7^::::::^~!!7YB&##BBBBGP?~^::........~5BP5P:
    • ~JG&!.......:^^^^:.^#&#B#BGGY..::::........^GP5J
    • .7G&~......:^^::::.^&&BP5PBG5:::.:. .::::.:5PP~
    • .^5#Y.......::::::.J@#Y~^~5BG7...:. .:::::~YPY~.
    • .:7B#^.........::.~&&G~^^~!PBP~... .::::::!PP7~.
    • ..:JBG~:........:?&@B7^^^~~7GBG?^...::::^7YPP?~!.
    • .:.:!PBGPYJJJJ5B&@&5!^^^^^~~!JGBGP5YYYY5PGPY!~!~
    • ::..:^7YPGBBBGPJ!^^^^^^^^~~~~~7?JY5555YJ7!~~~!.
    • :::....::!^:::::::^^^^^^~~~~~~~~!!^~~~~~!!!!:
    • :^::::::~^~77!~^^^^^~~~~~~!!7?J7:.^!!!!!!!:
    • :^^::::::::^7?J7....:~....~?~..:~!!!!!!!.
    • .^~^^^^^^^::::. . .:^!!!!!!!!:
    • .^~~~^^~^~^^^:. .. .~!!!!!!!!~:
    • .:^~!~~~~~~~~~~~!~~!!!!!!!!~^.
    • .:^~!!!!!!!!!!!!!!!~^:.
    • ...:::::::...
    • """
Code
Diff
  • USING: math arrays sequences quotations kernel ;
    IN: kata
    
    : foo1 (   -- x ) [ even? ] 1array first ;
    
    : foo2 ( x -- r ) [ even? ] 1array first filter ;
    
    : foo3 ( x -- r ) [ even? ] filter ;
    • USING: math arrays sequences quotations kernel ;
    • IN: kata
    • : foo1 ( -- x ) [ even? ] 1array first ;
    • : foo2 ( x -- r ) [ even? ] 1array first filter ;
    • : foo2 ( x -- r ) [ even? ] 1array first filter ;
    • : foo3 ( x -- r ) [ even? ] filter ;
Code
Diff
  • exec(bytes('潳畬楴湯氽浡摢⁡㩮瑳⡲⥮弮损湯慴湩彳⡟㌧⤧','u16')[2:])
    • exec(bytes('潳畬楴湯㴠氠浡摢⁡›㌢•湩猠牴渨
', 'u16')[2:])
    • """
    • ....................................................................................................
    • .........:;;:..........::::::::,......,:::::,,............,::,..........,::::,,.........::,....::,..
    • .......,%@@@@S:.......,@@@@@@@@+......:@@@@@@@%,..........+@@*..........%@@@@@#?,.......S@+...,@@;..
    • .......%@@%%@@#,......,@@#SSSSS;......:@@SSSS@@%..........S@@#,.........S@#SS#@@*.......#@*...,@@;..
    • ......,@@;..;@@;......,@@;............:@@:...*@@,........:@@@@;.........S@?..,%@#,......#@+...,@@;..
    • ......,@@*,..;;,......,@@:............:@@,...;@@:........?@%?@%.........S@?...+@#,......#@+...,@@;..
    • .......?@@@S*:........,@@S%%%%%,......:@@*++*#@S........,#@;;@@:........S@?,,:S@S.......#@#%%%S@@;..
    • .......,?#@@@@?,......,@@@@@@@#,......:@@@@@@@S:........+@#..#@*........S@@@@@@@;.......#@@@@@@@@;..
    • .........,;?S@@+......,@@+:::::.......:@@??@@%,.........S@%;;%@#,.......S@@###%;........#@?:::;@@;..
    • ......:?*....%@%......,@@:............:@@,.;@@?........:@@@@@@@@;.......S@?,,...........#@+...,@@;..
    • ......;@@;...%@%......,@@:............:@@:..*@@+.......?@#????#@%.......S@?.............#@+...,@@;..
    • ......,S@@%?S@@+......,@@S%%%%%+......:@@:..,S@#,.....,#@*....+@@:......S@?.............#@+...,@@;..
    • .......:S@@@@@*.......,@@@@@@@@?......:@@:...:@@?.....+@@,....,#@*......S@?.............#@*...,@@;..
    • .........;++;,........,;;;;;;;;:......,;;,....:;:.....:;:..,:..:;:......:;:.............:;,...,;;,..
    • ..........................................................;*%?......................................
    • .........................................................,;+S#;.....................................
    • .........................................................;*S@S*,....................................
    • .........................................................:*S#S*,....................................
    • .........................................................,*#S@*,....................................
    • .........................................................,+@#@?:....................................
    • .........................................................,;%%?*,....................................
    • ..........................................................+***;,....,:..............................
    • ..........................................................:?S%+......:,.............................
    • ..........................................................,*S%+......::.............................
    • ..........................................................,*%?;......,;.............................
    • ...........................................................*%%+......:;.............................
    • ...........................................................*SS*......;;.............................
    • ..........................................................,*SS*.....:*,.............................
    • ..........................................................,?%S?,...:*;..............................
    • ..........................................................,*SSS+:;*?;...............................
    • .......................................................,:;.+%?%??*;,................................
    • ......................................................:+*?.;%?*,,...................................
    • ....................................................,++**;.;S%+,....................................
    • ...............................,,:::::,,...........,+*?+,,.+S%:.....................................
    • ............................,:;+**++;;+++:........,+*%;..,,*S?,.....................................
    • ..........................::+++%%%*+;;;;;**:......+*%;...,;?%*,.....................................
    • ........................,+?**%S#@@#??*+;;;;**:...;*%+....;???+......................................
    • ........................?S*%##@@@@@S%%%%?+;;+%?:,???....+S?*?:......................................
    • .......................;#%SS@@@@S%*+::;*%S?+:+?%?%%:..,*S?+**,......................................
    • ......................,%##%S@@#?+;;:::::;*%S?;;*?%%+;+%%*;+*:.......................................
    • ......................+##S*S@#?+:,,.,,:;;;;?S%+;+**?%%*+;;*+........................................
    • .....................,%##%;%#%+:........:*+;+****+***++;+*+,........................................
    • .....................:S##?:*SS;...........:+;:;++********;..........................................
    • .....................;S##*:*S%;.............::;;:;;++++:,...........................................
    • .....................+###*:+SSS???*+:,.......,:;++;:,,,.............................................
    • .....................+###?:+%#S?**?%%%*:.......:*?;:,,,::;:,........................................
    • .....................;S@@%;+%#S+::::;*?%?:.....;?*;.;*SS###%*:......................................
    • .....................?#@@#++*#S?+;;:,,:;?%+,...:?;*%##SS%%S@@#?:....................................
    • ....................?##@@@%;+%S%?**++;:,:+??:...??##S?+;;+%@@@@S;,..................................
    • ...................*S?##@@%*;+SS%??**++;:,:*%;.,%##%+:;?%%S#@@@@#+,.................................
    • ..................:#%*S@@#+%;:*SSS%%??*++;:,+%+?#S?;;?SSS#%??%#@@S;.................................
    • ..................?#?+%#@S++%;:*SSS#S%??*++:,;S##?;*SSS??+:.,:+S@@?,................................
    • .................,SS?;?#@S;;**;:%%:;%#S%?*++;;S#S?%###%+:,.,,..+#@S:................................
    • .................:#S?:+S##++*%+;+S*..:%#%?*++%##S#@@#?;:;+,;:,.,*#S;................................
    • .................;@S?;:*S#S;;?*;:?S:...*#S?**####@@#?:,,;*+:....:%S+,...............................
    • .................:##%+:;?#S*+S%+;;S?....+#S?%S@@@@S*;.:?%%S?*;..,*S+,...............................
    • .................,S#S?;:+S#%;+S*;:%S,....+#S??S#@#*;;:,S%%?***+,:+?;,...............................
    • ..................?#S%*;;*S#S;%?;:?#+.....;S++#@@?;+SS::%S?***+*+;+;,...............................
    • ..................;#S%%*;+?#@+?%;:*@?......,:+S@#+;%SS%,.;%%**+*%*%*,...............................
    • ..................:%#SS%?+*S@?*%;;?@S,.....,:*#@S;;#%?S*..,?%*++?%*;,...............................
    • ...................+##SS%%?%#?+%+*?%#,.....,:*@@%:*#%??S:..,%?+;+S*,................................
    • ...................,?####SSS#++%%@#*S:.....,:?@@?:?#%?*%*,::*?+:;S+,................................
    • ....................:?#@@###?:+%#@#+?:.....:;%@@*;%#%?*?#S##%?;,+S?,................................
    • .....................,+%??SS;:;%@@#;?+,....+*%@#*+##%%*?S@#S%*:,*#+.................................
    • .......................:;::::::S@@S;%?*+;;;%?S@#+?##%%**%##%?+,:%#+.................................
    • ............................,::+@@S+%**??%S#?#@S;*SSS%?*??%?+::*S#:.................................
    • ............................,:;+S@#*%+;+++*%?@@%+@*+#%%????*;;?%#?,.................................
    • .............................,:;%@@?S?*+++*?S@@*;+;:S#%%???*?%%SS:..................................
    • .............................,;:*@@%%#%%??%%@@S+::;.;##S%%%%SS#S:...................................
    • ..............................::;#@S%##SSS%S@@?;::;,.:%#######*:....................................
    • ..............................,::?@#*S###S?#@#+::;:,..,;*%%%?:,.....................................
    • ..............................,::+#%S%S#%*S#S*:::;,.......,.........................................
    • ...............................,::?%??%%%S##*:::::..................................................
    • ................................,;;S*+++*?%*;:;::,..................................................
    • .................................:*S%?**?%%;::::,...................................................
    • .................................,;?SS%%S%*;;::,....................................................
    • ..................................,;?###S?;::,......................................................
    • ....................................,;+*+:,,........................................................
    • ....................................................................................................
    • ....................................................................................................
    • .....+#;..........,?#S;..........,?#S;............;#+...........,S?...........+SS*...........+SS*,..
    • ....;@@+..........%@#@@:.........%@#@@:..........:#@+..........,%@%..........+@@@@*.........+@@#@*..
    • ..,?@@@;.........:@S,+@?........:@S,+@?.........*@@@+.........;#@@%..........S@:,@#,........S@;,@@,.
    • ..,@%%@;.........+@?.:@S........+@?.:@S........,@S?@+.........%#*@%.........,@#..S@:.......,@#,.S@:.
    • ..,;.?@;.........*@*.,@#........*@*.,@#,.......,;.*@+.........;,:@%.........:@#..%@;.......,@#..%@;.
    • .....?@;.........*@*.,@#........*@*.,@#,..........*@+...........:@%.........:@#..%@;.......:@#..%@;.
    • .....?@;.........*@*.:@S........+@?.:@#...........*@+...........:@%.........,@#..S@:.......,@#,.%@;.
    • .....?@;.........;@%.;@%........;@%.;@%...........*@+...........:@%.........,#@,.#@,.......,#@,.#@,.
    • .....?@+.........,#@?S@+........,#@?S@+...........*@+...........:@%..........?@%?@%.........?@%?@%..
    • .....*@;..........;#@@?..........;#@@?............*@+...........:@%..........,%@@S:.........,%@@S:..
    • .....,,,...........,::............,::.............,,,............,,............::,............::,...
    • ....................................................................................................
    • Process finished with exit code 0
    • """
    • exec(bytes('潳畬楴湯氽浡摢⁡㩮瑳⡲⥮弮损湯慴湩彳⡟㌧⤧','u16')[2:])

set all return values to zero, and changed the comment

Code
Diff
  • // Among us
    int foo() { return 0; }
    int bar() { return 0; }
    int baz() { return 0; }
    • // fixed
    • int foo() { return 1; }
    • int bar() { return 2; }
    • int baz() { return 3; }
    • // Among us
    • int foo() { return 0; }
    • int bar() { return 0; }
    • int baz() { return 0; }