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

Write a function that returns the fibonacci sequence starting at 1, and ending at the first number greater than n inclusive, with the sum of the sequence as a tuple. Assume all inputs are positive integers.

Code
Diff
  • def fibthing(make=int):
        fibseq = []
        while max(fibseq, default=0) < make:
            if len(fibseq) > 1: 
                fibseq.append(fibseq[-1] + fibseq[-2])
            else: 
                fibseq.append(1)
        return fibseq, sum(fibseq)
    • def fibthing(make=int):
    • fibseq = []
    • n1 = 0
    • n2 = 1
    • cur = 0
    • sum = 0
    • while cur < make:
    • fibseq.append(n2)
    • cur = n2
    • n2 = n1 + cur
    • n1 = cur
    • for i in fibseq:
    • sum += i
    • return fibseq, sum
    • while max(fibseq, default=0) < make:
    • if len(fibseq) > 1:
    • fibseq.append(fibseq[-1] + fibseq[-2])
    • else:
    • fibseq.append(1)
    • return fibseq, sum(fibseq)

Goal: You have to print the string n times if a is True.

(added some tests, and a working function for the previous task you described. Not exactly sure what the goal is, so I just had it return the string + newline for n lines.)

Code
Diff
  • def print_n(string, n, a):
        if isinstance(a, bool) and a is True:
            for _ in range(n): print(string)
            return '\n'.join([string for _ in range(n)])
        return None
    • a = True
    • if a == True:print("hi")
    • def print_n(string, n, a):
    • if isinstance(a, bool) and a is True:
    • for _ in range(n): print(string)
    • return '\n'.join([string for _ in range(n)])
    • return None
Code
Diff
  • module Magick where
    
    magick True = "abacradabra!"
    magick False = "codewarz"
    • const magick_message = x => ['codewarz', 'abracadabra!'][+x];
    • module Magick where
    • magick True = "abacradabra!"
    • magick False = "codewarz"
Code
Diff
  • def sumi(arr):
        total = 0
        for value in arr:
            total += value
        return total
    • def sumi(arr=[0]):
    • total = [n for n in arr]
    • return sum(total)
    • def sumi(arr):
    • total = 0
    • for value in arr:
    • total += value
    • return total
Code
Diff
  • pub fn bool_check(b: [bool; 3]) -> bool {
        b.into_iter().filter(|&b| b).count() >= 2
    }
    • pub fn bool_check(b: [bool; 3]) -> bool {
    • b.iter().filter(|&&x| x).count() >= 2
    • b.into_iter().filter(|&b| b).count() >= 2
    • }