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
public class PalindromeArray {

    public static void main(String[] args) {
    int[] array = {1983, 89, 121, 32, 12321, 90, 178};
    for (int index = 0; index < array.length ; index++) {
        if (isPalindrome(array[index])){
            System.out.println(array[index]);
            }
        }
    }

    public static boolean isPalindrome(int number) {
        int originalNumber = number;
        int reverse = 0;
        while (number > 0) {
            int digit = number % 10;
            reverse = reverse * 10 + digit;
            number = number / 10;
        }
        return originalNumber == reverse;
    }
}

This is a string of Lists and their indexs and then reverses the list.

def print_String(List):
    
    # Printing the index of a string in the list.
    List = ['double', 'switch', 'off', 'on', 'jump']
    index = List.index('double')
    print (index)
    
    # Reversing the items in the list
    List.reverse()
    
    print ('Reversed List:', List)

Prints Hello world

def Hello_World(Hellow_World):
    print ("Hello World")
Arrays
Data Types

Given a 2D integer matrix, format it to print the matrix with each character occupying a minimum width.

import java.lang.StringBuilder;
import java.util.Arrays;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.stream.Collectors;

public class Kata {
  public static String stringify2dArray(int[][] array, int width) {
    String pattern = "%" + width + "s";
    return Arrays.stream(array)
        .map(formatRow(pattern))
        .collect(StringBuilder::new, StringBuilder::append, StringBuilder::append)
        .toString();
  }

  private static Function<? super int[], ? extends String> formatRow(String pattern) {
    return row -> Arrays.stream(row)
        .mapToObj(formatCell(pattern))
        .collect(Collectors.joining(" ")) + "\n";
  }

  private static IntFunction<? extends String> formatCell(String pattern) {
    return cell -> String.format(pattern, cell);
  }
}

Your challenge is to write a Python script that prints “Hello Mark” along with other lines of code. Your code must be original and include comments. Print statements are a good resource to use for debugging. Use the sample script as an example.

def Print_Statements():
    # Prints "Hello Mark!"
    print ("Hello Mark!")

    # Prints "This is my first python script"
    print ("This is my first python script.")

    # Prints "Python will be fun to learn!"
    print ("Python will be fun to learn!")

    # Prints "I am not at COGS, I am at home in my jammies."
    print ("I am not at COGS, I am at home in my jammies.")

    # Prints "Ani Morrow's script has ended...have a great semester!"
    print ("Ani Morrow's script has ended...have a great semester!")

Throughout this activity you will create a new folder called MyFolder in the D:Python\Data location. You will use the Toolbox to find the tool that creates a folder, then you will use ArcGIS Help to find the scripting syntax for that tool.

Always check if the code runs. Errors are common.

# Importing os
import os

# Creating a variable path to the new folder
Path = r"D:\Python\Data\MyFolder"

# Checking the folder exists
if not os.path.exists(Path):# to see if the folder already exists
    os.makeirs(Path)# makes all intermediate-level directories needed to contain the leaf directory.

sci tech

print("hi")

There is a queue for the self-checkout tills at the supermarket. Your task is write a function to calculate the total time required for all the customers to check out!

input
customers: an array of positive integers representing the queue. Each integer represents a customer, and its value is the amount of time they require to check out.
n: a positive integer, the number of checkout tills.
output
The function should return an integer, the total time required.

Important
Please look at the examples and clarifications below, to ensure you understand the task correctly :)

Examples
queue_time([5,3,4], 1)

should return 12

because when n=1, the total time is just the sum of the times

queue_time([10,2,3,3], 2)

should return 10

because here n=2 and the 2nd, 3rd, and 4th people in the

queue finish before the 1st person has finished.

queue_time([2,3,10], 2)

should return 12

Clarifications
There is only ONE queue serving many tills, and
The order of the queue NEVER changes, and
The front person in the queue (i.e. the first element in the array/list) proceeds to a till as soon as it becomes free.
N.B. You should assume that all the test input will be valid, as specified above.

P.S. The situation in this kata can be likened to the more-computer-science-related idea of a thread pool, with relation to running multiple processes at the same time: https://en.wikipedia.org/wiki/Thread_pool

class Queue:
    def __init__(self, arr=[]):
        self.arr = arr
        self.wait_time = sum(i for i in arr)
    
    def enqueue(self, num):
        self.arr.append(num)
        self.wait_time += num
    
    def dequeue(self):
        return self.arr.pop(0)
    
def queue_time(customers, n):
    # TODO
    customer_queue = Queue(customers)
    if n == 1:
        return customer_queue.wait_time
    
    queues = [Queue([]) for i in range(n)]
    while len(customer_queue.arr)>=1:
        wait = [k.wait_time for k in queues]
        for i in queues:
            if i.wait_time == min(wait) or i.wait_time == 0:
                i.enqueue(customer_queue.dequeue())
                break
                
    return max([i.wait_time for i in queues])
Fundamentals
Strings
Data Types
Algorithms
Logic

A palindrome is a word spelt the same forwards and backwards.
If word is not a palindrome return False and if word is a palindrome return True.

Examples:

anna = True
hotdog = False
civic = True
kayak = True
codewars = False

def palindrome(word):
    if word[::-1] == word:
        return True
    else:
        return False

Hello World

A method that returns "Hello World".

Module Kumite
    Function HelloWorld()
        return "Hello World"
    End Function
End Module