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
  • матем = Math
    Math.найтиМаксимальное = матем.max
    _ = (...числа) => матем.найтиМаксимальное(...числа)
    • Математика = Math
    • Математика.максимум = Математика.max
    • _ = (...числа) => Математика.максимум(...числа)
    • матем = Math
    • Math.найтиМаксимальное = матем.max
    • _ = (...числа) => матем.найтиМаксимальное(...числа)
Games
Arrays

OK, RESPONSE: Pure Terror Everybody Will Have Nightmares About Coding

Code
Diff
  • final class WordChain {
     static boolean validate(String[]w,int n){
      if(w==null||w.length<2||n<1)return false;
      int c=1;while(c<w.length<<1)c<<=1;
      String[]k=new String[c];int[]h=new int[c];int m=c-1;
      for(int i=0;i<w.length;i++){
       String s=w[i];if(s==null||s.length()<n)return false;
       if(i>0)for(int j=0;j<n;j++)
        if((w[i-1].charAt(w[i-1].length()-n+j)|32)!=(s.charAt(j)|32))return false;
       int x=0;for(int j=0;j<s.length();j++)x=31*x+(s.charAt(j)|32);
       for(int j=x&m;;j=j+1&m){
        String t=k[j];
        if(t==null){k[j]=s;h[j]=x;break;}
        if(h[j]==x&&t.length()==s.length()){
         int z=0,L=s.length();
         while(z<L&&(t.charAt(z)|32)==(s.charAt(z)|32))z++;
         if(z==L)return false;
        }
       }
      }
      return true;
     }
    }
    
    //NUH UH
    • final class WordChain{
    • static boolean validate(String[]a,int n){
    • // in the beginning there was darkness (and bitwise operators)
    • if((a==null)|((a!=null)&(a.length<2))|(n<1))return false;
    • int C=1,need=a.length<<1;for(;C<need;C<<=1); // power-of-two table size
    • final int M=C-1;
    • final String[]K=new String[C];
    • final int[]H=new int[C];
    • for(int i=0;i<a.length;i++){
    • String s=a[i];
    • if(s==null||s.length()<n)return false;
    • if(i!=0){
    • String p=a[i-1];
    • int pl=p.length();
    • for(int j=0;j<n;j++){
    • // lowercase via "trust me bro" algebra
    • if((((p.charAt(pl-n+j)^32)|32))!=(((s.charAt(j)^32)|32)))return false;
    • }
    • }
    • int x=0;
    • for(int j=0,L=s.length();j<L;j++){
    • x=((x<<5)-x)+(s.charAt(j)|32); // == 31*x + lowercased char
    • x^=(x>>>16); // pointless-ish mixing, but deterministic
    • x^=(x>>>16);
    • }
    • // linear probing, but make it feel like a fever dream
    • for(int j=x;;j=(j+1)&M){
    • int q=j&M;
    • String t=K[q];
    • if(t==null){
    • K[q]=s;H[q]=x;
    • break;
    • }
    • if(H[q]==x && t.length()==s.length()){
    • final class WordChain {
    • static boolean validate(String[]w,int n){
    • if(w==null||w.length<2||n<1)return false;
    • int c=1;while(c<w.length<<1)c<<=1;
    • String[]k=new String[c];int[]h=new int[c];int m=c-1;
    • for(int i=0;i<w.length;i++){
    • String s=w[i];if(s==null||s.length()<n)return false;
    • if(i>0)for(int j=0;j<n;j++)
    • if((w[i-1].charAt(w[i-1].length()-n+j)|32)!=(s.charAt(j)|32))return false;
    • int x=0;for(int j=0;j<s.length();j++)x=31*x+(s.charAt(j)|32);
    • for(int j=x&m;;j=j+1&m){
    • String t=k[j];
    • if(t==null){k[j]=s;h[j]=x;break;}
    • if(h[j]==x&&t.length()==s.length()){
    • int z=0,L=s.length();
    • for(;z<L && (((t.charAt(z)|32)^0)==((s.charAt(z)|32)^0));z++);
    • while(z<L&&(t.charAt(z)|32)==(s.charAt(z)|32))z++;
    • if(z==L)return false;
    • }
    • // dead code with teeth (never runs, still confusing)
    • if(false && (q==~q))return (Boolean)(Object)true;
    • }
    • }
    • return !false;
    • return true;
    • }
    • }
    • //NUH UH
Code
Diff
  • import sum from require "pl.seq"
    sum_letters: (b, c) -> #b + #c > 1 and sum({ b\byte 1, -1 }) == sum({ c\byte 1, -1 })
    • import sum from require "pl.seq"
    • sum_letters: (a, b) -> #a + #b > 1 and sum({ a\byte 1, -1 }) == sum({ b\byte 1, -1 })
    • sum_letters: (b, c) -> #b + #c > 1 and sum({ b\byte 1, -1 }) == sum({ c\byte 1, -1 })