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

Obtain previous number

object Previous {
  def previous(num: Int): Int =
    num-1
}

input two objects:
classroom={x:x1,y:y1};
teacher={x:x2,y:y2};
give another float d,
that is how long you shouts.
return 'fuck dude!'if the teachercannothear.
return 'shut up!'ifhe can hear out.
return 'sit well!'if he is in the classroom.
(i cannot say english so well.)

//
def function():
    answer=a*b
    return answer
Fundamentals
Mathematics
Algorithms
Logic
Numbers
Strings
Data Types

Ques 7: Input type String. Output type number. Print out the maximum even number which can be generated by making combinations of numbers present in the given string. Each number can be used only once ie. No Redundancy.

Example1:
Input String = Infytq@218412
Intermediate step (List of numbers //redundancy removed) = [2,1,8,4]
Output Number = 8412

Example2
Input String = someString&337
Intermediate step (List of numbers //redundancy removed) = [3,7]
Output Number = -1

def maximum_even_no(string):
    list1=[]
    list2=[]
   
    for i in string:
        if(i.isdigit()):
            list1.append(i)
    list1=list(dict.fromkeys(list1))
    list2=sorted(list1,reverse=True)
    if(int(list2[-1])%2==0 or int(list2[-1])==0):
        return int("".join(list2))
    list3=range(len(list2))
    list3=sorted(list3,reverse=True)
    for j in list3:
        if(int(list2[j])%2==0):
            temp=list2.pop(j)
            list2.append(temp)
            break
    result="".join(list2)
    if(int(result)%2==0):
        return int(result)
    else:
        return -1

Takes a string of an even length, splits it in two and intertwines those to generate the output string.
e.g intertwine('135246') --> '123456'
intertwine('11223344') --> '13132424'

def intertwine(text):
    return ''.join([val+'' for pair in zip(text[:len(text)//2], text[len(text)//2:]) for val in pair])

Swing list sorting:
Examples:

special_sort(list) -> list
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] # input
[0, 9, 1, 8, 2, 7, 3, 6, 4, 5] # output
def special_sort(list):
    r = []
    l = len(list)
    for i in range(l // 2 + 1):
    	if i == 0 or (i == l // 2 and not l % 2):
    		r.append(list[i])
    	else: r.extend([list[-i], list[i]])
    return r

Sebastian and Patricia want to know if the sum digits of their years is greater than the sum digits of their mother's years?

Example: (27,3,1)

  1. Mother = 27
  2. Sebastian = 3
  3. Patricia = 1

Calculate: (2+7) < (3+1) => false

public class AgeSumDigits
{
  public static boolean SumOfDigits(int[] ages) {   
  int m = ages[0];
  int s = ages[1];
  int p = ages[2];
  // Coding with passion ;)    
  return (calcSum(m) < calcSum(s)+calcSum(p)) ? true : false;
      
  } 
  
  static int calcSum(int age){
    int sum = 0;
    while(age>0){
      sum += age % 10;
      age /= 10;
    }
    return sum;
  }
}

You have received 2 names.

Verify if the sum of letters of the 1 name is the same as sum of the letters of the 2 name. If the name or surname is null output NULL.

For example:

  1. "Anna" and "Nana"
    "Anna" = 65+110+110+97 = 382
    "Nana" = 78+97+110+97 = 382
    Result: "Anna" and "Nana" => "TRUE"

  2. "Sebastian" and "Patricia" => "FALSE"

  3. "John" and null => "NULL"

class Kata{
  
  public static String verifySum(String nameOne, String nameTwo) {
        int[] sumOfNames = new int[]{0, 0};
        
        if (nameOne == null || nameTwo == null) {
            return "NULL";
        }
        
        for (int i = 0; i < nameOne.length(); i++){
            sumOfNames[0] += nameOne.charAt(i);
        }
        
        for (int i = 0; i < nameTwo.length(); i++){
            sumOfNames[1] += nameTwo.charAt(i);
        }
        
        return sumOfNames[0] == sumOfNames[1] ? "TRUE" : "FALSE";
    }
}
#include <stdlib.h>
#include <string.h>

char *my_strdup_1(const char *str) {
  const size_t len = strlen(str);
  char *const res = malloc(len); // <- BUG
  memcpy(res, str, len);
  return res;
}

char *my_strdup_2(const char *str) {
  const size_t len = strlen(str);
  char *const res = malloc(len); // <- BUG
  memcpy(res, str, len + 1);
  return res;
}
const interwine = str => 
   [...str]
      .reduce((r,_,i,s) => 
         i%2 ? 
         [...r,s[(s.length+i-1)/2]] :
         [...r,s[i/2]], [])
      .join('')