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

You have to create a function that given an array of integers returns the largest product that can be made by multiplying any 3 integers in the array.

Example:

[-4, -4, 2, 8] should return 128 as the largest product can be made by multiplying -4 * -4 * 8 = 128.

def maximum_product_of_three(lst):

    max_pr = 0
    num_num = 0

    for num in lst:
        for i in range(0,len(lst)):
            if i != lst[num_num] and num_num+2 < len(lst):
                try:
                    if (num*lst[i+1]*lst[i+2])>max_pr:
                        max_num = num*lst[i+1]*lst[i+2]
                except:
                    pass
        num_num =+ 1

    return max_num
using System; 
public class Sum
{
   public int GetSum(int a, int b)
   {
      return a + b;
   }
}
Bash
Regular Expressions
Declarative Programming
Advanced Language Features
Programming Paradigms
Fundamentals
Strings

You have two lists you need to know what is in list two, that is not in list one:

missing file1.list file2.list

Two Lists

MacBook-Air:codewar dusty$ cat one
one
two
three
four
six
MacBook-Air:codewar dusty$ cat two
one
two
three
four
five

What is in list two, but not in list one:

MacBook-Air:codewar dusty$ missing one two
five
function missing() {     cat $1 <(cat $1 $2 ) <(cat $2 $1 | sort | uniq -c | tr -d ' ' | grep '^1' | sed 's/1//') | sort |  uniq -c | tr -d ' ' | grep '^2' | sed 's/2//'; }
USING: math ;
IN: multiplier

: multiply ( a b -- a*b ) * ;

In JavaScript the most popular way of inverting strings would be something, similar to [...str].reverse().join('').

And what would be your unusual way?

const invert = str => str.replace(/./g, (_,o,s) => s.charAt(s.length-1-o));
starlightFailed Tests

Test

print(2+4)

When asked about closest to N integer divisible by n, you might think of a neat and simple n*Math.round(N/n).

But, is there anything even more concise and fast?

closestMultiple=(N,n)=>n*(N/n+0.5>>0)

Your task is to write a function sortWithoutSort() that accepts an array of arbitrary length n with integer values v as an argument. sortWithoutSort() should return the sorted array in ascending order. You should not use Array.sort() to achieve this.

function sortWithoutSort(array) {
  for (let i = 0; i < array.length; i++) {
    if (i < array.length - 1) {
      if (array[i] > array[i+1]) {
        var sortVal = array.splice(i,1)[0];
        array.splice(i+1, 0, sortVal);
        sortWithoutSort(array);
      }
    }  
  }  
  
  return array;
}

The totient function of a number is defined as the number of numbers less than that number that do not share a factor with that number.

Define a function totient(a) that computes the totient of a number.

def totient(a):
    out = 0
    for b in range(a):
        if(gcd(a, b) == 1):
            out += 1
    return out
    
def gcd(a, b):
    while b != 0:
        (a, b) = (b, a % b)
    return a

You get a sentence in a string. Convert every word that has 4 letters or is longer to the word "yeet". If the sentence is longer than 4, it should replace the word with "yeet" but with as many "e"s as there are other letters except the ones on the ends.
It should return the sentence with the words that were changed and the words that weren't changed at the same place as they were before. It should also keep the punctations.
Have fun yeeting words

public class yeet {

  public static String yeetWords(String Words){
	    String[] s = Words.split(" ");
	    String end = "";    
      String r = "";
	    if(s[s.length-1].endsWith(".") || s[s.length-1].endsWith("!") || s[s.length-1].endsWith("?")){
	      end = s[s.length-1].substring(s[s.length-1].length()-1);
	    }
      for(int i = 0; i<s.length; i++){
        String st = s[i];
        String rs = "";
        int le = st.length()-1;
        if(st.length() >= 4){
          if(st.endsWith(end)){
            le = le-1;
          }
          rs = "y" + st.substring(1,1);
          for(int e = 1; e<le; e++){
            rs = rs + "e";
          }
          rs = rs + "t";
        } else {
          rs = st;
        }
        r = r + rs + " ";
      }
	    return r.trim() + end;
  }

}