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

take a number as input say (n) and add all the digit of this numnber until result is not equal to a single digit no.

EX. 1245358,
output=1+2+4+5+3+5+8=28, 28=2+8=10, 10=1+0=1
so, output=1

n=int(input())
                                                                                   


for i in range(n):
    add=add+n[i]
    if add>9:
        while add<10:
            for j in range(add):
                add+=add[j]
                print(add)
    else:
        print(add)
hanukaFailed Tests

BinaryGap

Fundamentals
Logic

A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.

For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps. The number 32 has binary representation 100000 and has no binary gaps.

Write a function:

that, given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap.

For example, given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap is of length 5. Given N = 32 the function should return 0, because N has binary representation '100000' and thus no binary gaps.

function binaryGap($n) {
  
}
def abbrev(str):
    return str[0] + str(len(str[1::-1])) + str[-1]
unit module Solution;
error-here
const s = `6,3,15,13,1,0`;

const input = s.split(',').map(Number);
const a = Array(2020);
const indexes = {};
const lastIndexes = {};
input.forEach((x, i) => ((a[i] = x), (indexes[x] = i), (lastIndexes[x] = i === input.length - 1 ? -1 : i)));

for (let i = input.length; i < 2020; i++) {
  const x = a[i - 1];
  if (indexes[x] === i - 1) {
    a[i] = 0;
    if (indexes[0] === undefined) indexes[0] = i;
    lastIndexes[x] = i - 1;
    continue;
  }
  a[i] = i - 1 - lastIndexes[x];
  lastIndexes[x] = i - 1;
  if (indexes[a[i]] === undefined) indexes[a[i]] = i;
}

console.log(a[2020 - 1]);
const add = (a, b) => a + b + 1;

Ваша задача - написать тело функции которая будет вычислять формулы.

Формула передаётся через параметр forlmula. Формулы могут содержать в себе все значения, но также можно передать переменные вида $1, $2, $3 и т.д.
Значения переменных передаются вторым параметром в неограниченном кол-ве.

Посмотрите тесты что бы понять что от вас требуется.

Удачи! Она вам потребуется ;)

======

Your task is to write the body of a function that will calculate formulas.

The formula is passed through the forlmula parameter. Formulas can contain all values, but you can also pass variables like $1, $2, $3, etc.
Variable values are passed as the second parameter in an unlimited number.

Look at the tests to understand what is required of you.

Good luck! You will need it;)

using System;

public class Calculator
{
  public static float Calculate(string forlmula, params float[] values)
  {
    // your code
  }
}
module Kata where

add_ :: Int -> Int -> Int
add_ a b = a + b

I would love to see a generator which accepts [(Gen s, Int)] and uses a set of generators, generates n inputs from each of them, shuffles them, and uses the inputs to feed test cases.

For example, for "Is a number prime?" kata, I'd like to have a composite generator built like compositeGen([(genPrimes, 100), (genOddComposites, 100), (genNegativePrime, 10), (genSquareOfAPrime, 20)]) or something like this, and it would run test cases over 230 shuffled inputs.

Bonus points if such generator were able to generate not only Int, but also (Int, Bool) (input + expected answer) or even (Int, Bool, String) (input, expected answer, and assertion message).


The one thing I can't fix is that if it fails, it's always after 1 test. Because that's what it sees.

module Example (isPrime) where

isPrime :: Int -> Bool
isPrime = odd

give me two candy!

pekora(a,b)=> 'candy';
add(a)=> 'candy';