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
Functions
Control Flow
Basic Language Features
Fundamentals

This solution uses a simple hash for holding stringified args to quickly lookup the cache.

The assumption is that only one type of function signature is ever used.

Fundamentals
Code
Diff
  • using System.Numerics;
    
    public class basic 
    {
    		public static BigInteger pow(long down, ulong up)
    		{
    			BigInteger output = 1;
    			BigInteger cumulativeDown = down;
    
    			for(ulong bitChecker = 1; bitChecker > 0 && bitChecker <= up; bitChecker <<= 1)
    			{
    				if((bitChecker & up) != 0)
    				{
    					output *= cumulativeDown;
    				}
    
    				cumulativeDown *= cumulativeDown;
    			}
    
    			return output;
    		}
    }
    • using System.Numerics;
    • public class basic
    • {
    • public static BigInteger pow(long down, long up)
    • => up == 0 ? 1 : down * pow(down, up - 1);
    • public static BigInteger pow(long down, ulong up)
    • {
    • BigInteger output = 1;
    • BigInteger cumulativeDown = down;
    • for(ulong bitChecker = 1; bitChecker > 0 && bitChecker <= up; bitChecker <<= 1)
    • {
    • if((bitChecker & up) != 0)
    • {
    • output *= cumulativeDown;
    • }
    • cumulativeDown *= cumulativeDown;
    • }
    • return output;
    • }
    • }
Code
Diff
  • let spaceMaker=str=>[...str].join(' ');
    • function spaceMaker(str) {
    • return str.split("").join(" ");
    • }
    • let spaceMaker=str=>[...str].join(' ');
Code
Diff
  • import java.util.stream.*;
    
    class Solution {
    
      public static String largestNumber(final Integer[] nums) {
        return Stream.of(nums)
          .sorted((a,b)->(""+b+a).compareTo(""+a+b))
          .collect(Collectors.reducing("",(x)->""+x,String::concat));
      }
    }
    • import java.util.stream.*;
    • class Solution {
    • public static String largestNumber(final Integer[] nums) {
    • return Stream.of(nums)
    • .sorted((a,b)->(""+b+a).compareTo(""+a+b))
    • .map(n->""+n)
    • .collect(Collectors.joining());
    • .collect(Collectors.reducing("",(x)->""+x,String::concat));
    • }
    • }
Code
Diff
  • # What are all the ways to output a string in Ruby?
    def hello_ruby
      greet = "Hello Ruby!"
    
      print           greet, "\n"
      puts            greet
      print           "#{greet}\n"
      puts            "Hello Ruby!"
      $stdout.write   greet + "\n"
      $stdout.puts    greet
      $stdout.print   greet, "\n"
      $stdout <<      greet + "\n"
      (greet+"\n").each_char {|c| print c}
    end
    • # What are all the ways to output a string in Ruby?
    • def hello_ruby
    • greet = "Hello Ruby!"
    • print greet, "\n"
    • puts greet
    • print "#{greet}\n"
    • puts "#{greet}"
    • puts "Hello Ruby!"
    • $stdout.write greet + "\n"
    • $stdout.puts greet
    • $stdout.print greet, "\n"
    • $stdout << greet + "\n"
    • (greet+"\n").each_char {|c| print c}
    • end
Code
Diff
  • def fib(x):
        fib = [1,1]
        for x in range(x-1):
            fib.append(fib[-2]+fib[-1])
        return fib[-1]
    • def _fib(n):
    • k = n.bit_length()-1
    • x0, x1 = 1, 0
    • y0, y1 = 0, 1
    • for i in range(k, -1, -1):
    • y2 = y0*y0
    • y0, y1 = 2*y0*y1+y2, y2+y1*y1
    • if (n>>i)&1:
    • xy = x0*y0
    • y0, y1 = x0*y1+x1*y0+xy, xy+x1*y1
    • return y0
    • def fib(n):
    • return _fib(n+1)
    • def fib(x):
    • fib = [1,1]
    • for x in range(x-1):
    • fib.append(fib[-2]+fib[-1])
    • return fib[-1]