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
Algorithms
Arrays
Mathematics
Geometry
Code
Diff
  • makeMove=(c,s)=>[...s].reduce((r,d)=>[r[0]+(d=='r')-(d=='l'),r[1]+(d=='t')-(d=='b')],c)
    • makeMove
    • =(c,s)=>
    • [...s].reduce((r,d)=>[r[0]+(d=='r')-(d=='l'),r[1]+(d=='t')-(d=='b')],c)
    • makeMove=(c,s)=>[...s].reduce((r,d)=>[r[0]+(d=='r')-(d=='l'),r[1]+(d=='t')-(d=='b')],c)
Code
Diff
  • import random
    
    class ArchitecturalGame:
        def __init__(self):
            self.score = 0
            self.level = 1
            self.max_level = 3
            self.choices = ["Design a skyscraper", "Renovate an old building", "Plan a city layout"]
            self.projects = ["Design a residential complex", "Renovate a historic landmark", "Create an eco-friendly city district"]
        
        def display_menu(self):
            print("Welcome to the Architectural Game!")
            options = self.choices if self.level <= self.max_level else self.projects
            menu_type = "Choose an option:" if self.level <= self.max_level else "Choose a project:"
            
            print(menu_type)
            for i, option in enumerate(options):
                print(f"{i + 1}. {option}")
        
        def play(self):
            self.display_menu()
            options = self.choices if self.level <= self.max_level else self.projects
            
            while True:
                try:
                    choice = int(input("Enter your choice: "))
                    if 1 <= choice <= len(options):
                        if self.level <= self.max_level:
                            self.process_choice(choice)
                        else:
                            self.process_project(choice)
                        break
                    else:
                        print("Invalid choice. Please try again.")
                except ValueError:
                    print("Invalid input. Please enter a number.")
        
        def process_choice(self, choice):
            if self.level <= self.max_level:
                print(f"You chose to {self.choices[choice - 1].lower()}.")
                self.score += random.randint(1, 10) * self.level
                self.display_score()
                self.level += 1
                if self.level <= self.max_level:
                    self.play()
            else:
                print("Your architectural firm is now established! Clients are approaching you with projects.")
                self.play()
        
        def process_project(self, project_choice):
            print(f"You chose to work on: {self.projects[project_choice - 1]}")
            self.score += random.randint(1, 10)
            self.display_score()
            self.level += 1
            if self.level <= self.max_level + 1:
                self.play()
        
        def display_score(self):
            print(f"Your current score is: {self.score}")
    
    # Main function
    def main():
        game = ArchitecturalGame()
        game.play()
    
    if __name__ == "__main__":
        main()
        
       
    • import random
    • class ArchitecturalGame:
    • def __init__(self):
    • self.score = 0
    • self.level = 1
    • self.max_level = 3
    • self.choices = ["Design a skyscraper", "Renovate an old building", "Plan a city layout"]
    • self.projects = ["Design a residential complex", "Renovate a historic landmark", "Create an eco-friendly city district"]
    • def display_menu(self):
    • print("Welcome to the Architectural Game!")
    • if self.level <= self.max_level:
    • print("Choose an option:")
    • for i, choice in enumerate(self.choices):
    • print(f"{i + 1}. {choice}")
    • else:
    • print("Your architectural firm is now established! Clients are approaching you with projects.")
    • print("Choose a project:")
    • for i, project in enumerate(self.projects):
    • print(f"{i + 1}. {project}")
    • options = self.choices if self.level <= self.max_level else self.projects
    • menu_type = "Choose an option:" if self.level <= self.max_level else "Choose a project:"
    • print(menu_type)
    • for i, option in enumerate(options):
    • print(f"{i + 1}. {option}")
    • def play(self):
    • self.display_menu()
    • options = self.choices if self.level <= self.max_level else self.projects
    • while True:
    • try:
    • choice = int(input("Enter your choice: "))
    • if 1 <= choice <= len(options):
    • if self.level <= self.max_level:
    • self.process_choice(choice)
    • else:
    • self.process_project(choice)
    • break
    • else:
    • print("Invalid choice. Please try again.")
    • except ValueError:
    • print("Invalid input. Please enter a number.")
    • def process_choice(self, choice):
    • if self.level <= self.max_level:
    • choice = int(input("Enter your choice: "))
    • if choice < 1 or choice > len(self.choices):
    • print("Invalid choice. Please try again.")
    • print(f"You chose to {self.choices[choice - 1].lower()}.")
    • self.score += random.randint(1, 10) * self.level
    • self.display_score()
    • self.level += 1
    • if self.level <= self.max_level:
    • self.play()
    • else:
    • self.process_choice(choice)
    • else:
    • project_choice = int(input("Enter the project you want to work on: "))
    • if project_choice < 1 or project_choice > len(self.projects):
    • print("Invalid choice. Please try again.")
    • self.play()
    • else:
    • self.process_project(project_choice)
    • def process_choice(self, choice):
    • if choice == 1:
    • self.design_skyscraper()
    • elif choice == 2:
    • self.renovate_building()
    • elif choice == 3:
    • self.plan_city_layout()
    • print("Your architectural firm is now established! Clients are approaching you with projects.")
    • self.play()
    • def process_project(self, project_choice):
    • print(f"You chose to work on: {self.projects[project_choice - 1]}")
    • self.score += random.randint(1, 10)
    • self.display_score()
    • def design_skyscraper(self):
    • print("You chose to design a skyscraper.")
    • # Implement logic for designing a skyscraper
    • self.score += random.randint(1, 10) * self.level
    • self.display_score()
    • def renovate_building(self):
    • print("You chose to renovate an old building.")
    • # Implement logic for renovating a building
    • self.score += random.randint(1, 10) * self.level
    • self.display_score()
    • def plan_city_layout(self):
    • print("You chose to plan a city layout.")
    • # Implement logic for planning a city layout
    • self.score += random.randint(1, 10) * self.level
    • self.display_score()
    • self.level += 1
    • if self.level <= self.max_level + 1:
    • self.play()
    • def display_score(self):
    • print(f"Your current score is: {self.score}")
    • if self.level < self.max_level:
    • print("Advancing to the next level...")
    • self.level += 1
    • self.play()
    • else:
    • print("Congratulations! You completed all levels.")
    • self.level += 1
    • self.play()
    • # Main function
    • def main():
    • game = ArchitecturalGame()
    • game.play()
    • if __name__ == "__main__":
    • main()
Code
Diff
  • //Created by RHB
    // Your code here
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main() {
      string H, W;
      H="Hello ";
      W="World!";
      
      cout << H << W << endl;
      return 0;
    }
    • ## Created by RHB
    • # Your code here
    • [print(chr(i),end="") for i in [100, 108, 114, 111, 87, 32, 111, 108, 108, 101, 72][::-1]]
    • //Created by RHB
    • // Your code here
    • #include <iostream>
    • #include <string>
    • using namespace std;
    • int main() {
    • string H, W;
    • H="Hello ";
    • W="World!";
    • cout << H << W << endl;
    • return 0;
    • }
Strings
Code
Diff
  • function isUnique(string) {
    const newString = new Set(string)
      return newString.size === string.length
    }
    
    • function isUnique(string) {
    • let knownChars = "";
    • for (let char of string) {
    • if (!knownChars.includes(char)) {
    • knownChars += char;
    • } else {
    • return false;
    • }
    • }
    • return true;
    • }
    • const newString = new Set(string)
    • return newString.size === string.length
    • }
Code
Diff
  • function dumbRockPaperScissors(player1, player2) {
      if (player1 === player2) return "Draw";
      
      const condition = {
        Scissors: "Paper",
        Rock: "Scissors",
        Paper: "Rock",
      };
      
      if (player2 === condition[player1]) return "Player 1 wins";
      return "Player 2 wins";
      
    }
    • function dumbRockPaperScissors(player1, player2) {
    • let condition = {
    • if (player1 === player2) return "Draw";
    • const condition = {
    • Scissors: "Paper",
    • Rock: "Scissors",
    • Paper: "Rock",
    • };
    • switch (true) {
    • case player2 === condition[player1]: return "Player 1 wins";
    • case player1 === condition[player2]: return "Player 2 wins";
    • case player1 === player2: return "Draw";
    • }
    • if (player2 === condition[player1]) return "Player 1 wins";
    • return "Player 2 wins";
    • }
Code
Diff
  • def number_of_primes(n):
        p, i = [], 2
        while len(p) < n:
            if all(i % d for d in range(2, int(i**0.5) + 1)):
                p.append(i)
            i += 1
        return p
    • def pri(n):
    • return n == 2 or n % 2 and n > 2 and all(n % i for i in range(3, int(n ** .5) + 1, 2))
    • def Number_of_Primes(n):
    • if not isinstance(n, int) or n < 0:
    • return "Invalid input"
    • prime = [2]
    • i = 3
    • while len(prime) < n:
    • if pri(i):
    • prime.append(i)
    • i += 2
    • return prime
    • def number_of_primes(n):
    • p, i = [], 2
    • while len(p) < n:
    • if all(i % d for d in range(2, int(i**0.5) + 1)):
    • p.append(i)
    • i += 1
    • return p