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
  • #simple calculator witha all functions
    
    function = input('+,-,/,*: ')
    number1 = input('n1: ')
    number2 = input('n2: ')
    
    
    
    if function == '+':
        sum = number1 + number2
        print(sum)
        
    elif function == '-':
        diff = number1 - number2
        print(diff)
        
    elif function == '*':
        product = number1 * number2
        print(product)
        
    elif function =='/':
        answer = number1 / number2
        print(answer)
        
    else:
        print('No related function')
    • #simple calculator witha all functions
    • function = 'add'
    • number1 = 2
    • number2 = 8
    • function = input('+,-,/,*: ')
    • number1 = input('n1: ')
    • number2 = input('n2: ')
    • if function == 'add':
    • if function == '+':
    • sum = number1 + number2
    • print(sum)
    • elif function == 'substract' or 'minus':
    • elif function == '-':
    • diff = number1 - number2
    • print(diff)
    • elif function == 'multiply':
    • elif function == '*':
    • product = number1 * number2
    • print(product)
    • elif function =='divide':
    • elif function =='/':
    • answer = number1 / number2
    • print(answer)
    • else:
    • print('No related function')
Code
Diff
  • x = "Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!"
    y = [21,1,8,27,88,9,478,97,18,34,129]
    print("".join(x[z] for z in y))
    • import codecs
    • exec(codecs.encode('cevag(pbqrpf.rapbqr("".wbva([v sbe v va pbqrpf.rapbqr("uryyb jbeyq",rapbqvat="ebg13",reebef="vtaber")]),rapbqvat="ebg13",reebef="vtaber"))',encoding="rot13",errors="ignore"))
    • x = "Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's do more of those!"
    • y = [21,1,8,27,88,9,478,97,18,34,129]
    • print("".join(x[z] for z in y))
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 solution(param):
    • return [x for x in param if isinstance(x,bool)].count(True) > 1
    • 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
  • function* blaze_it() {
      yield 69;
      yield 420;
      yield 1337;
    };
    
    const dark_tech = blaze_it()
    
    let a=10;
    a = dark_tech.next().value;
    a = dark_tech.next().value;
    a = dark_tech.next().value;
    const b = 42;
    a = 10*b;
    a= 12;
    a - Math.sin(Math.PI / 2);
    • function* blaze_it() {
    • yield 69;
    • yield 420;
    • yield 1337;
    • };
    • const dark_tech = blaze_it()
    • let a=10;
    • a = 69;
    • a = 420;
    • a = dark_tech.next().value;
    • a = dark_tech.next().value;
    • a = dark_tech.next().value;
    • const b = 42;
    • a = 10*b;
    • a= 11;
    • a= 12;
    • a - Math.sin(Math.PI / 2);
Code
Diff
  • package kumite
    import "time"
    
    func CheckWorkHours(dateTime time.Time) bool {
    	return true &&
    		dateTime.Weekday() != time.Thursday &&
    		dateTime.Weekday() != time.Sunday &&
    		dateTime.Hour() >= 8 &&
    		dateTime.Hour() < 18
    }
    
    • package kumite
    • import "time"
    • func CheckWorkHours(dateTime time.Time) bool {
    • return dateTime.Weekday() != time.Thursday && dateTime.Weekday() != time.Sunday && dateTime.Hour() >= 8 && dateTime.Hour() < 18 }
    • func CheckWorkHours(dateTime time.Time) bool {
    • return true &&
    • dateTime.Weekday() != time.Thursday &&
    • dateTime.Weekday() != time.Sunday &&
    • dateTime.Hour() >= 8 &&
    • dateTime.Hour() < 18
    • }
Mathematics

Returning zero on edge cases is incorrect, fixed it.

Code
Diff
  • def Calculator(*args):
        operators = {
            '+': lambda a, b: a + b,
            '-': lambda a, b: a - b,
            '*': lambda a, b: a * b,
            '/': lambda a, b: a / b if b != 0 else float('inf')
        }
        
        if len(args) != 3 or str(args[0]) not in operators:
            return float('nan')
        
        operator, operand1, operand2 = args
        return operators[operator](operand1, operand2)
    
    • def Calculator(*args):
    • operators = {
    • '+': lambda a, b: a + b,
    • '-': lambda a, b: a - b,
    • '*': lambda a, b: a * b,
    • '/': lambda a, b: a / b if b != 0 else 0
    • '/': lambda a, b: a / b if b != 0 else float('inf')
    • }
    • if len(args) != 3 or str(args[0]) not in operators:
    • return 0
    • return float('nan')
    • operator, operand1, operand2 = args
    • return operators[operator](operand1, operand2)