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
Functional Programming
Algorithms
Mathematics
Code
Diff
  • export const checkIfAtOrBelowLimit = (driverSpeeds: number[], speedLimit: number): number[] => {
      return driverSpeeds.map(speed => CalculateFine(speed, speedLimit));
    }
    const CalculateFine = (speed: number, limit: number) => {
      if(speed >= limit + 30) return 500
      if (speed >= limit + 20 && speed <= limit + 29) return 250
      if (speed >= limit + 10 && speed <= limit + 19) return 100
      return 0
    }
    • export const checkIfAtOrBelowLimit = (driverSpeeds: number[], speedLimit: number): number[] => {
    • return driverSpeeds.map(speed => CalculateFine(speed, speedLimit));
    • }
    • const CalculateFine = (speed: number, limit: number) => {
    • if(speed > limit + 30) return 500
    • if (speed > limit + 20 && speed < limit + 29) return 250
    • if (speed > limit + 10 && speed < limit + 19) return 100
    • if(speed >= limit + 30) return 500
    • if (speed >= limit + 20 && speed <= limit + 29) return 250
    • if (speed >= limit + 10 && speed <= limit + 19) return 100
    • return 0
    • }
Date Time
Code
Diff
  • function ShowDate() {
      const days = {'1':'st','2':'nd','3':'rd'};
      const date = new Date().toLocaleDateString('en', {month: 'long', day: 'numeric', year: 'numeric'})
      const dateFixed = date.replace(',', days[new Date().getDate()]?? 'th')
      return dateFixed
    }
    • function ShowDate() {
    • const months = {'Jan':'January','Feb':'February','Mar':'March','Apr':'April','May':'May',
    • 'Jun':'June','Jul':'July','Aug':'Augest','Sep':'September','Oct':'October',
    • 'Nov':'November','Dec':'December'};
    • const days = {'1':'st','2':'nd','3':'rd'};
    • return new Date().toDateString().slice(4).split(' ').map((e,i) => i?i==1?+e+(days[e.slice(-1)]||'th'):e:months[e]).join(' ');
    • const date = new Date().toLocaleDateString('en', {month: 'long', day: 'numeric', year: 'numeric'})
    • const dateFixed = date.replace(',', days[new Date().getDate()]?? 'th')
    • return dateFixed
    • }

i fixed it

Code
Diff
  • use std::arch::asm;
    
    #[cfg(target_arch = "x86_64")]
    pub fn multiply(a: usize, b: usize) -> usize {
        let mut result: usize;
        unsafe {
            asm!(
                "mov {result}, 0",
                "2:",
                "add {result}, {a}",
                "dec {b}", // i mean like no ones gonna notice if we modify it :3
                "cmp {b}, 0",
                "ja 2b",
                a = in(reg) a,
                b = in(reg) b,
                result = out(reg) result,
            );
        }
    
        result
    }
    • fn multiply(a: usize, b: usize) -> usize {
    • a * b
    • use std::arch::asm;
    • #[cfg(target_arch = "x86_64")]
    • pub fn multiply(a: usize, b: usize) -> usize {
    • let mut result: usize;
    • unsafe {
    • asm!(
    • "mov {result}, 0",
    • "2:",
    • "add {result}, {a}",
    • "dec {b}", // i mean like no ones gonna notice if we modify it :3
    • "cmp {b}, 0",
    • "ja 2b",
    • a = in(reg) a,
    • b = in(reg) b,
    • result = out(reg) result,
    • );
    • }
    • result
    • }
Code
Diff
  • #include <stdio.h>
    prnt_mltply(m,n){for(int i=1;i<=m;i++)for(int j=1;j<=n;j++)printf("%d * %d = %d\n",i,j,i*j);return m*n;}
    • #include <stdio.h>
    • int prnt_mltply(int m, int n) {
    • for (int i = 0; i < m; i++) for (int j = 1; j <= n; j++) printf("%d * %d = %d
    • ", i + 1, j, (i+1) * j);
    • return m * n;
    • }
    • prnt_mltply(m,n){for(int i=1;i<=m;i++)for(int j=1;j<=n;j++)printf("%d * %d = %d
    • ",i,j,i*j);return m*n;}
Code
Diff
  • #include <iostream>
    #include <string>
    using namespace std;
    
    bool helloWorld() {
      return [](const string &H, const string &W){
        return (cout << H << W << endl).good();
      }("Hello, ", "World!");
    }
    • //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;
    • bool helloWorld() {
    • return [](const string &H, const string &W){
    • return (cout << H << W << endl).good();
    • }("Hello, ", "World!");
    • }
Code
Diff
  • firstNonRepeatingCharacter=s=>(j=s.split``,r=j.reduce((o,c)=>(o[c]=(o[c]??0)+1,o),{}),j.find(c=>r[c]==1)??null)
    • const firstNonRepeatingCharacter = (str) => {
    • let counts = {};
    • for(const char of str) {
    • counts[char] = 1 + (counts[char] ? counts[char] : 0);
    • }
    • for(const char in counts) {
    • if(counts[char] == 1) {
    • return char;
    • }
    • }
    • return null;
    • }
    • firstNonRepeatingCharacter=s=>(j=s.split``,r=j.reduce((o,c)=>(o[c]=(o[c]??0)+1,o),{}),j.find(c=>r[c]==1)??null)