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

Just realized bug in the problem. If there are 2 negative lengths and 1 positive lengths, it will still return a positive integer. Thus, we test if the cube is valid in the first place.

Code
Diff
  • def kube(l,w,h):
        if l < 0 or w < 0 or h < 0:
            return "Invalid Cube"
        else:
            return l * w * h
    
    • kube = lambda l, w, h: max(l * w * h, 0)
    • def kube(l,w,h):
    • if l < 0 or w < 0 or h < 0:
    • return "Invalid Cube"
    • else:
    • return l * w * h
Code
Diff
  • def cap(low, high, num):
        x, y = min(low, high, num), max(low, high, num)
        return sum([low, high, num]) - sum([x, y])
    
    • def cap(low, high, num):
    • if num < low: return low
    • elif num > high: return high
    • else: return num
    • x, y = min(low, high, num), max(low, high, num)
    • return sum([low, high, num]) - sum([x, y])
Code
Diff
  • from inspect import getsource
    
    
    def quine():
        source = getsource(quine)
        message = 'CodeWars'
    
        return source
    • from inspect import getsource
    • def quine():
    • q = '"' * 3
    • s = """def quine():
    • q = '"' * 3
    • s = %s%s%s
    • return s %% (q, s, q)
    • """
    • return s % (q, s, q)
    • source = getsource(quine)
    • message = 'CodeWars'
    • return source
Fundamentals
Restricted
Code
Diff
  • is_even=lambda*x:not(x[len("")]%(True+True))
    • is_even=lambda*x:not(x[int()]&True)
    • is_even=lambda*x:not(x[len("")]%(True+True))
Code
Diff
  • p=1
    • p=lambda x:x
    • p=1
Code
Diff
  • result = lambda n: (n > 70) * n // 10 or 'fail'
    • result = lambda n: [n // 10, 'fail'][n < 70]
    • result = lambda n: (n > 70) * n // 10 or 'fail'

Naive solution.

I think this would be more interesting if the challenge was to generate as few characters of b**infuck as possible.

maybe add a limit to *ra*nfuck characters in the test cases? might be fun.

Code
Diff
  • #include<stddef.h>
    #include<string.h>
    #include<stdlib.h>
    
    char buf[4096] = {0};
    char*
    s2bf(char *arr) {
    	char cv = 0;
    	char *r;
    	
    	while(*arr){
    		while(cv != *arr){
    			strcat(buf, "+");
    			cv++;
    		}
    		strcat(buf, ".");
    		arr++;
    	}
    	
    	r = malloc(4096);
    	strcpy(r, buf);
    	return r;
    }
    • #include<stddef.h>
    • #include<string.h>
    • #include<stdlib.h>
    • char s[4096] = "";
    • char buf[4096] = {0};
    • char*
    • s2bf(char *argv) {
    • register int i = 0,j;
    • register int k,m;
    • register int l,last = 0;
    • while (argv[++i]!=0)
    • continue;
    • for (j=0; j<i; j++) {
    • register int t;
    • t = argv[j];
    • l = k = t-last;
    • last = t;
    • #ifdef DEBUG
    • printf("\n%d, %d, %d, %d\n",last,k,j,i);
    • #endif
    • if (k >= 0) {
    • k >>= 3; // k /= 8
    • l &= 7; //在更多的机器工作,求余
    • if (k == 1)
    • strcat(s,">++++++++");
    • else {
    • if (k != 0) {
    • strcat(s,"++++++++[>");
    • for (m=0; m<k; m++)
    • strcat(s,"+");
    • strcat(s,"<-]>");
    • } else {
    • strcat(s,">");
    • }
    • }
    • for (m=0; m<l; m++)
    • strcat(s,"+");
    • strcat(s,".");
    • } else {
    • k = -k >> 3; // k /= 8
    • l = -l & 7; //在更多的机器工作,求余
    • if (k == 1)
    • strcat(s,">--------");
    • else {
    • strcat(s,"++++++++[>");
    • for (m=0; m<k; m++)
    • strcat(s,"-");
    • strcat(s,"<-]>");
    • }
    • for (m=0; m<l; m++)
    • strcat(s,"-");
    • strcat(s,".");
    • s2bf(char *arr) {
    • char cv = 0;
    • char *r;
    • while(*arr){
    • while(cv != *arr){
    • strcat(buf, "+");
    • cv++;
    • }
    • #ifdef DEBUG
    • printf("\n%d, %d, %d\n",m,k,l);
    • #endif
    • strcat(s,"<");
    • strcat(buf, ".");
    • arr++;
    • }
    • char* q = malloc(4096);
    • strcpy(q, s);
    • return q;
    • r = malloc(4096);
    • strcpy(r, buf);
    • return r;
    • }
Code
Diff
  • av=Math.abs
    • av=n=>Math.abs(n)
    • av=Math.abs