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
Strings
Code
Diff
  • use std::collections::BTreeSet;
    
    fn is_unique(string: &str) -> bool {
        string.chars().collect::<BTreeSet<_>>().len() == string.len()
    }
    
    • use std::collections::BTreeSet;
    • fn is_unique(string: &str) -> bool {
    • let mut known = BTreeSet::new();
    • for character in string.chars() {
    • if known.contains(&character) {
    • return false;
    • }
    • known.insert(character);
    • }
    • true
    • string.chars().collect::<BTreeSet<_>>().len() == string.len()
    • }
Algorithms
Arrays
Mathematics
Geometry
Code
Diff
  • fn make_move(init: (i32, i32), sequence: &str) -> (i32, i32) {
        sequence.chars().fold(init, |(x, y), c| (
            x + match c { 'r' => 1, 'l' => -1, _ => 0 },
            y + match c { 't' => 1, 'b' => -1, _ => 0 },
        ))
    }
    • fn make_move(init: [i32; 2], sequence: &str) -> [i32; 2] {
    • sequence.chars().fold(init, |[x, y], c| [
    • x + (c == 'r') as i32 - (c == 'l') as i32,
    • y + (c == 't') as i32 - (c == 'b') as i32,
    • ])
    • fn make_move(init: (i32, i32), sequence: &str) -> (i32, i32) {
    • sequence.chars().fold(init, |(x, y), c| (
    • x + match c { 'r' => 1, 'l' => -1, _ => 0 },
    • y + match c { 't' => 1, 'b' => -1, _ => 0 },
    • ))
    • }
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;
    • }