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
# 90 degrees clockwise matrix rotate
def rotate(m):
    return list(zip(*m))[::-1]
Encoding
Algorithms
Logic

Create a function, that takes string as its only argument and yields rot13-encoded string. Only standard latin letters must be affected, avoid touching other characters and whitespaces.

defmodule Rot13 do
  def rotate({k, v}) do
    cond do
      v in ?A..?M ->
        k + 13

      v in ?N..?Z ->
        k - 13

      true ->
        k
    end
  end
  
  def encode(str) do
    List.zip([
      str
      |> String.to_charlist(),
      str
      |> String.upcase()
      |> String.to_charlist()
    ])
    |> Enum.map(&rotate/1)
    |> List.to_string()
  end
end

The function take a number and checks if it is in the Fibonnacci Sequence. If it is return "yes", else return "no".

Fibonnacci sequence explained:
starts with 0 and 1. It adds the two previous numbers to get the next one, then continues the pattern.

Some of the beginning sequence: 0,1,1,2,3,5,8,13,21...

function isSquare(x) { 

  // code goes here  
  let sq = parseInt(Math.sqrt(x));
  return check = (sq * sq == x)
}

function FibonacciChecker(num){
  return (isSquare(5 * num * num + 4) || isSquare(5 * num * num -4)) ? "yes" : "no";
  
}

In this kata you are restructuring given object with agregated properties by underscore into nested object

Sample transformation :

const before = {
a_b_c : 'value'
}

restructured into:

const after = {
a : {
b: {
c: 'value'
}
}
}

export function transform(obj: any) {
    const _RegEx = new RegExp(/_/);
    const underscoredProp = Object.keys(obj).find(key =>
        _RegEx.test(key)) || '';
    const value = obj[underscoredProp];
    const propertList = underscoredProp.split('_').reverse();
    let toAdd = {};

    propertList.map((prop,index) => {
       toAdd = index==0 ?{[prop]:value}  : {[prop]:toAdd}
        
    })

    return toAdd;
}
const {execSync} = require('child_process');
execSync(`echo '{"foo": "bar"}' >file.json`);
console.log(require('./file.json'));
execSync(`echo '{"baz": "qux"}' >file.json`);
console.log(require('./file.json')); // cached

ALLOW FRIENDS TO ADD ME THROUGH KUMITE

#include<iostream>

std::string dfescribe(std::string){
  
};
/*
Description:
"7777...8?!??!", exclaimed Bob, "I missed it again! Argh!" Every time there's an interesting number coming up, he notices and then promptly forgets. Who doesn't like catching those one-off interesting mileage numbers?
Let's make it so Bob never misses another interesting number. We've hacked into his car's computer, and we have a box hooked up that reads mileage numbers. We've got a box glued to his dash that lights up yellow or green depending on whether it receives a 1 or a 2 (respectively).
It's up to you, intrepid warrior, to glue the parts together. Write the function that parses the mileage number input, and returns a 2 if the number is "interesting" (see below), a 1 if an interesting number occurs within the next two miles, or a 0 if the number is not interesting.
Note: In Haskell, we use No, Almost and Yes instead of 0, 1 and 2.
"Interesting" Numbers
Interesting numbers are 3-or-more digit numbers that meet one or more of the following criteria:
Any digit followed by all zeros: 100, 90000
Every digit is the same number: 1111
The digits are sequential, incementing†: 1234
The digits are sequential, decrementing‡: 4321
The digits are a palindrome: 1221 or 73837
The digits match one of the values in the awesomePhrases array
† For incrementing sequences, 0 should come after 9, and not before 1, as in 7890.
‡ For decrementing sequences, 0 should come after 1, and not before 9, as in 3210.
So, you should expect these inputs and outputs:
// "boring" numbers
isInteresting(3, [1337, 256]);    // 0
isInteresting(3236, [1337, 256]); // 0
// progress as we near an "interesting" number
isInteresting(11207, []); // 0
isInteresting(11208, []); // 0
isInteresting(11209, []); // 1
isInteresting(11210, []); // 1
isInteresting(11211, []); // 2
// nearing a provided "awesome phrase"
isInteresting(1335, [1337, 256]); // 1
isInteresting(1336, [1337, 256]); // 1
isInteresting(1337, [1337, 256]); // 2
Error Checking
A number is only interesting if it is greater than 99!
Input will always be an integer greater than 0, and less than 1,000,000,000.
The awesomePhrases array will always be provided, and will always be an array, but may be empty. (Not everyone thinks numbers spell funny words...)
You should only ever output 0, 1, or 2.
*/
const chars = n => n.toString().split("");
const match = s => n => new RegExp(n).test(s);

const tests = [
  match("1234567890"), // incremental
  match("9876543210"), // decremental
  n => /^\d[0]+$/.test(n), // all zeroes
  n =>
    n ==
    chars(n)
      .reverse()
      .join(""), // palindrome
  n => [...new Set(chars(n))].length === 1 // repeated
];

const test = (n, xs) =>
  n > 99 && (xs.indexOf(n) > -1 || tests.map(t => t(n)).some(x => !!x));

const isInteresting = (n, xs) =>
  test(n, xs) ? 2 : +(test(n + 1, xs) || test(n + 2, xs));
Regular Expressions
Declarative Programming
Advanced Language Features
Programming Paradigms
Fundamentals
Strings

With the power of regex it becomes easy to tell if your string has even length!

class StringParity {
  public static boolean isEvenLength(String str) {
    return str.replaceAll("(?s)..", "").isEmpty(); // (?s) enables DOTALL
  }
}

In this simple exercise, you will build a program that takes a value, integer , and returns a list of its multiples up to another value, limit . If limit is a multiple of integer, it should be included as well. There will only ever be positive integers passed into the function, not consisting of 0. The limit will always be higher than the base.

For example, if the parameters passed are (2, 6), the function should return [2, 4, 6] as 2, 4, and 6 are the multiples of 2 up to 6.

If you can, try writing it in only one line of code.

def find_multiples(b, l):
    a=[]
    for i in range(b,l+1,b):
        
        a.append(i)
    return a
...