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.

Failed Tests

### Exercício 1

Dado o tamanho da base e da altura de um retângulo, calcular a sua área e o seu
perímetro.

let base = 8
let altura = 4
const area = base * altura
const perimetro = (2 * base) + (2 * altura)

console.log(`a área do retângulo é \${area} e o perímetro é \${perimetro}`)

### Object Oriented Programming: Circle Shape

Object-oriented Programming
Mathematics

## Background Info

In Object Oriented Programming (OOP), inheritence is a mechanism where you can to derive a set of class attributes and methods from a hierarchical class. Polymorphism refers to the ability of an object to take on multiple forms. For example, class objects belonging to the same hierarchical tree (inherited from a common parent class) may have functions with the same name, but with different behaviors.

## Objective

• Become familiar with OOP, and understand concepts of class inheritance, and polymorphism.

## Task

Develop a program that calculates the area of a circle using OOP, and demonstartes both inheritence,and polymorphism in the design. Include and update tests with any changes.

import math

class Shape:
"""A Shape base class."""

def __init__(self, color, thickness, location):
self.color = color
self.thickness = thickness
self.location = location

def __str__(self):
return f'{self.__class__.__name__}(color={self.color}, thickness={self.thickness}, location={self.location})'

def change_color(self, color):
self.color = color

class Circle(Shape):
"""A Circle class that inherits from Shape class."""
def __init__(self, radius, color, thickness, location):
super().__init__(color, thickness, location)
self.radius = radius

def __str__(self):
return f'{super().__str__()[:-1]}, radius={self.radius})'

def change_color(self, color):
"""Changes the color attribute of Shape. This is also an example of polymorphism"""
old, self.color = self.color, color
return f'The color has changed from {old} to {self.color}!'

def area(self):
"""Returns the area of a Circle"""
return math.pi * self.radius ** 2
Failed Tests

### Inf_TonY's Kumite #2

рандомная фигура

from tkinter import *
from random import randint
root = Tk()
root.geometry("300x300")
figura = ""
def randomf():
global figura
c.delete("all")
num = randint(1,3)
if num ==1:
figura = c.create_oval(10,10,20,30)
elif num == 2:
figura = c.create_rectangle(10,10,20,20)
else:
figura = c.create_polygon(10,10,20,40,20,20)
b = Button(text="Нажми", command=randomf)
b.place(x=0,y=270)
c = Canvas(bg="white", height=100,width=100)
c.pack()
root.mainloop()

### Binary to Decimal

int convert(char bin) {
int dec = 0;

for (int i = 7; i >= 0; i--) {
dec = dec << 1;
if ((bin & (1 << i)) != 0)
dec ++;
}
return dec;
}

### 100💯

💯

fn return_hundred() -> i32 { 100 }

### Vector multiply

Multiplies the elements inside a vector

fn vector_multiply(input: Vec<i32>) -> i32 {
let mut out = 1;
for i in input {
out *= i;
}
out
}

fn nothing() {}

### storing two 7 length cstrings in 128 bit integer

Strings

all described in title lol

__uint128_t solution(char* str1, char* str2) {
__uint128_t result = 0;

for (unsigned long i = 0; i < 7; ++i) {
result +=
(((__uint128_t) str1[i]) << (8*i)) +
(((__uint128_t) str2[i]) << (8*(i + 8)));
}

return result;
}

### Add numbers of an array

Given an array of numbers, return the total value of all the numbers.

function addArr(arr){

if(arr.length === 0) return null

let final = 0
arr.forEach(num => {
final += num
})
return final
}

### Caesar Cipher

Ciphers
Algorithms

The Caesar Cipher or the shift cipher, is a substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number position (i.e., shift) down the alphabet. This method is named after Julius Caesar, who used it during the Gallic Wars.

def caesar_cipher_encryption(message):
"""Caesar Cipher encryption"""
output = ''
for letter in message.upper():
if not letter.isalpha():
continue
cipher = ord(letter) + 1
if cipher > ord('Z'):
cipher = ord('A')
output += chr(cipher)
return output

def caesar_cipher_decryption(cipher):
output = ''
for letter in cipher.upper():
if not letter.isalpha():
continue
text = ord(letter) - 1
if text < ord('A'):
text = ord('Z')
output += chr(text)
return output