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

just messing with you :>

module Kumite where

main = do
  putStrLn "<DESCRIBE::>Kumite\n<PASSED::>Test Passed\n"
  print $ if if if if if True then True else False then True else False then True else False then True else False then 1 else 0
/**
 This is a Test
*/
function Solution() {
  return "Hello World"
}

//
function Test() {

}
Algorithms
Logic
Fundamentals

A Windows 95 cd key has ten digits, in the form of XXX-XXXXXXX.

The first segment (also named a site) must be 3 digits long, but cannot be 333, 444, 555, 666, 777, 888, or 999.

The second segment must be 7 digits long, divisble by 7, but the last digit can not be 0 or ≥ 8.

(adapted from this article)

function validateKey(key) {
  var segments = key.split('-');
  
  var illegalSites = [333, 444, 555, 666, 777, 888, 999];
  var illegalEnds = [0, 8, 9];
  
  if (segments.length != 2 
  || illegalSites.includes(+(segments[0])) || +(segments[0]) > 999 || +(segments[0]) < 0 || segments[0].length != 3
  || +(segments[1]) % 7 == true || illegalEnds.includes(+(segments[1].slice(-1))) || segments[1].length != 7) {return false}

  return true;
}
function Solution() {

}
Games
Arrays
Data Types
Algorithms
Logic

In our time, probably everyone played computer games, starting from Tetris and ending with grandiose game projects!

In many games with two-dimensional graphics, you can face the following situation. The hero jumps on platforms that hang in the air. Often the essence of such games is that the hero would move from point A to point B. At the same time, the hero has a level of life and energy. When jumping, the hero spends one life and spends energy, which is calculated by the formula |y2-y1|where y1 and y2 are the heights at which these platforms are located.

Let's assume that you know the coordinates of all the platforms in order from left to right. Can you find the minimum amount of energy the hero needs to get from the last platform to the first?

using System;
public static class Kata
{
  public static int CalculatingTheAmountEnergy(int[] coordinates)
  {
     // here's your code
  }
}

You have 100 cards, numbered 1 to 100. You distribute them into k piles and collect back the piles in order. For example, if you distribute them into 4 piles, then the first pile will contain the cards numbered 1, 5, 9, and the 4 th pile will contain the cards numbered 4, 8, 12, . While collecting back the cards you collect first the last pile, flip it bottom to top, then take the third pile, flip it bottom to top and put the cards on top of the 4th pile and so on. Next round, you distribute the cards into another set of piles and collect in the same manner (last pile first and first pile last).

If we have 10 cards, and put them into 2 piles, the order of the cards in the piles (top to bottom) would be 9, 7, 5, 3, 1 and 10, 8, 6, 4, 2
We flip the piles to get the order 1, 3, 5, 7, 9 and 2, 4, 6, 8, 10
We put the second pile at the bottom and first on top of it to get the deck 1, 3, 5, 7, 9, 2, 4, 6, 8, 10
Given the number of rounds (m), the number of piles in each round (ki), you need to write a program to find the Nth card from the top at the end of the final round.

Input:

The input consists of a single line of (m+2) comma-separated integers.
The first number is m, the number of rounds. The next m numbers are ki which represent the number of piles in each round.
The last number in the input is N, the position in the final pile whose value is to be determined.

Output:

One integer representing the Nth card after all rounds have been played.

Constraints: Number of rounds <= 10, number of piles in each round <= 13.

Example 1

Input: 2, 2, 2, 4

Output: 13

Explanation:
m = 2, k1 = 2, k2 = 2 and N = 4.
We have two rounds. The first round has two piles. At the end of the round, the deck is in the following order: 1, 3, 5, , 99, 2, 4, 6, , 100
The next round also has 2 piles and after the second round, the cards are in the order 1, 5, 9, 13, .
The fourth card from the top has number 13.

Example 2

Input: 3, 2, 2, 3, 2

Output: 13

Explanation:
m = 3, k1 = 2, k2 = 2, k3 = 3 and N = 2.
After the second round, the cards are in the order 1, 5, 9, 13,
The third round has 3 piles. Thus after this round the cards will be in the order 1, 13, . the Second card is 13.

import itertools
L=[i for i in range(1,101)]
L2=[]
A,*B,C=map(int,input().split())
for i in range(A):
    for k in range(B[i]):
        L2.extend(L[k:99:B[i]])
    L.clear()
    L.extend(L2)
    L2.clear()
print(L[C-1])

Add something to the function's logic so that it still returns 1!

def rubegoldberg():
    return 1

Find your way to discover an "a1", the inverse of the key(a1: a^(-1)), without using the brute-force loop like the example code
Then return the secret text

Note: a x a1 = 1 (modulo 26)
Example: 7 x -11 = 1 (modulo 26) >> a1 = -11

In order to find the secret text:
secret_text = ""
for c in ciphertext:
e = (a1 * (char2num(c) - b)) % m
secret_text = secret_text + num2char(e)

def char2num(c):
return ord(c) - 65

def num2char(n):
return chr(n + 65)

def a_little_decryption(a, b, m, ciphertext):
    secret_text = ""
    a1 = None
    for i in range(0, m):
        if (a*i)%m == 1:
            a1 = i
            break
    for c in ciphertext:
        e = (a1 * (char2num(c) - b)) % m
        secret_text = secret_text + num2char(e)
    return secret_text

from hex to 1 dec
'a:2:35:af:1' -> 10 + 2 + 53 + 175 + 1 -> 241
'b:356:3af:cba24:100' -> 11 + 854 + 943 + 834084 + 256 -> 836148

decr = lambda a: sum([int(h,16) for h in a.split(':')])

Count the number of occurrences of each character and return it as a list of tuples in order of appearance. For empty output return an empty list.

Example:

'''
OrderedCount("abracadabra") == []Tuple{Tuple{'a', 5}, Tuple{'b', 2}, Tuple{'r', 2}, Tuple{'c', 1}, Tuple{'d', 1}}

// Where
type Tuple struct {
Char rune
Count int
}
'''

package orderedcount

// Use the preloaded Tuple struct as return type
// type Tuple struct {
//	Char  rune
//	Count int
// }

func OrderedCount(text string) []Tuple {
 // to implement
}