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.
eğer parametreden verilen metin değer içinde tüm karakterler benzersiz ise true, tekrar eden bir karakter var ise false değer dönmeli.
Küçük-büyük karaketer fark etmez.
isIsogram "Dermatoglyphics" == true
isIsogram "moose" == false
isIsogram "aba" == false
using System;
using System.Linq;
public class Kata
{
public static bool IsIsogram(string str)
{
//return str.ToLower().Distinct().Count()==str.Length;
}
}
using NUnit.Framework;
using System;
using System.Collections.Generic;
[TestFixture]
public class BasicTests
{
private static IEnumerable<TestCaseData> testCases
{
get
{
yield return new TestCaseData("Dermatoglyphics").Returns(true);
yield return new TestCaseData("isogram").Returns(true);
yield return new TestCaseData("moose").Returns(false);
yield return new TestCaseData("isIsogram").Returns(false);
yield return new TestCaseData("aba").Returns(false);
yield return new TestCaseData("moOse").Returns(false);
yield return new TestCaseData("thumbscrewjapingly").Returns(true);
yield return new TestCaseData("").Returns(true);
}
}
[Test, TestCaseSource("testCases")]
public bool Test(string str) => Kata.IsIsogram(str);
}
given a number (n) return the text for hoe it is spoken. e.g.:
10 => "ten"
99 => "ninety nine"
-1 => "negative one"
231 => "two hundred and thirty one"
I will make the smallest number -999 and the largest 999 for simplicity. you can asume all numbers are valid intagers, but check the range. If a number is out of range return "unsupported number";
function Generrate (n)
{
var out = "";
var str_arrOfDigits = n.toString().split("");
if (str_arrOfDigits[0] == "-")
{
out += "negative ";
str_arrOfDigits.splice(0,1);
}
switch (str_arrOfDigits.length) {
case 1:
out += Digits(str_arrOfDigits[0]);
break;
case 2:
out += getDoubleDigit(str_arrOfDigits);
break;
case 3:
out += getTrippleDigit(str_arrOfDigits)
break;
default:
return "unsupported number";
break;
}
return out;
};
function Digits(n) {
return ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"][n];
};
function tens(n) {
return ["zero", "ten", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"][n];
};
function getDoubleDigit (arr)
{
var out = "";
if (arr[0] == "1") {
out = Digits(arr.join().replace("," ,""));
}
else {
if (arr[0] != "0")
out = tens(arr[0]) + (arr[1] != "0"? " " + Digits(arr[1]): "");
else
out = Digits(arr[1]);
}
return out;
}
function getTrippleDigit (arr)
{
var firstDigit = Digits(arr[0]);
var doubleDigits = getDoubleDigit(arr.splice(1));
return (firstDigit != "zero"? firstDigit + " hundred" : "") + (firstDigit != "zero" && doubleDigits != "zero"? " and " + doubleDigits : (doubleDigits != "zero"? doubleDigits : ""));
}
describe("Solution", function(){
it("Tests", function(){
Test.assertEquals(Generrate(1), "one", "obviousesly includes 1");
Test.assertEquals(Generrate(0), "zero", "should work with 0");
Test.assertEquals(Generrate(1000), "unsupported number", "out of range");
Test.assertEquals(Generrate(-10), "negative ten", "should work with negative numbers");
Test.assertEquals(Generrate(320), "three hundred and twenty", "should work with triple digits");
});
});
You and your friend only have a limit span of free time per day to meet, given your free hour range and his find if you will be able to meet.
Given a start hour and end hour for your free time and a start hour and end hour of your friend free time, write a function that return True or False if you will be able to meet with your friend.
The Hours will be given the 24 h format.
For example :
13 - 15 and 14 - 16 ==> true
0 - 3 and 23 - 2 ==> true
1 - 3 and 23 - 24 ==> false
#include <cmath>
static float hourToRad(int hour)
{
return (float) hour * (M_PI / 12.0);
};
static bool willTheyMeet(
int startHour1,
int endHour1,
int startHour2,
int endHour2)
{
auto a1 = hourToRad(startHour1);
auto a2 = hourToRad(endHour1);
auto b1 = hourToRad(startHour2);
auto b2 = hourToRad(endHour2);
if (a1 == b2 || a2 == b1)
return false;
float da = (a2 - a1) / 2.0;
float db = (b2 - b1) / 2.0;
float ma = (a2 + a1) / 2.0;
float mb = (b2 + b1) / 2.0;
float cda = cos(da);
float cdb = cos(db);
return cos(ma - b1) >= cda ||
cos(ma - b2) >= cda ||
cos(mb - a1) >= cdb ||
cos(mb - a2) >= cdb;
};
// TODO: Replace examples and use TDD development by writing your own tests
Describe(any_group_name_you_want)
{
It(should_do_something)
{
Assert::That(willTheyMeet(13, 15, 14, 16), Equals(true));
Assert::That(willTheyMeet(0, 3, 23, 2), Equals(true));
Assert::That(willTheyMeet(1, 3, 23, 24), Equals(false));
}
};
Introduction
My place of work changes all the time, and my Nokia Brick doesn't support Google Maps.
I need to find the fastest way to work through a variety of different locations - and I need user-friendly instructions that can be read out, since I can't look away from the road.
Your job in this kumite is to take an array (the map), and work out the fastest way from the hotel ('h'), to the office ('o') through the streets given. Driveable roads are represented by blankspace, and the map (and roads) are outlined by dashes ('-'). Then, compute some directions to take me there!
IF THERE IS NO POSSIBLE WAY TO GET TO THE OFFICE, RETURN "dont bother"
In the words of a great poet,
"The journey, not the arrival, matters." - T.S. Eliot
Tips
- You can assume that when I start, I am facing north.
- You can assume that there will be a route faster than the others.
- You can assume that the arrays will be the same length.
- I must travel onto the hotel.
- I will start on the outline of the map - moving into the map is an included step.
- You cannot assume that the I will start at the bottom of the map.
Result
You must return an array with strings inside, that can only be of the following:
"turn left", "turn right", "drive forward"
Bear in mind that "turning left" or "turning right" does not move me anywhere - I have car that rotates on the spot ;)
Example
[['-','o','-','-','-'],
['-',' ',' ',' ','-'],
['-',' ','-',' ','-'], This should return ["drive forward", "turn left", "drive forward", "turn right",
['-',' ','-',' ','-'], "drive forward", "drive forward", "drive forward", "drive forward"]
['-',' ',' ',' ','-'],
['-','-','h','-','-']]
Sidenotes
I have made extensive efforts to make sure this kumite is original. If this is not the case, and you cannot personally retire it, please drop a comment with a link to that kumite, and I would be happy to rectify my mistake.
Also, I am aware this is setup much like a kata - but unfortunately with a kata you need a working solution, which I can't make! Maybe when this is functional, it can be converted into a Kata. ;)
def directions(map):
return ["drive forward"]
Test.describe("Take me to work!")
Test.it("Should function.")
map = [['-','o','-'],['-',' ','-'],['-',' ','-'],['-',' ','-'],['-',' ','-'],['-','h','-']]
Test.assert_equals(directions(map), ["drive forward", "drive forward", "drive forward","drive forward","drive forward"])
Test.it("Should find the fastest route.")
map = [['-','o','-','-','-'],['-',' ',' ',' ','-'],['-',' ','-',' ','-'],['-',' ','-',' ','-'],['-',' ',' ',' ','-'],['-','-','h','-','-']]
# Cheeky using the example from the description, I know, but you can make more of your own maps - they're a pain!
Test.assert_equals(directions(map), ["drive forward", "turn left", "drive forward", "turn right","drive forward", "drive forward", "drive forward", "drive forward"])
Calculates the factorial of a given integer with applicative y-combinator (or z-combinator).
#lang racket/base
(define (y f)
((lambda (x) (f (lambda (v) ((x x) v))))
(lambda (x) (f (lambda (v) ((x x) v))))))
(define factorial
(y (lambda (partial)
(lambda (n) (if (zero? n) 1 (* n (partial (sub1 n))))))))
(factorial 50)
An if statement that passes the tested value to the body.
#lang racket
(require racket/stxparam)
(define-syntax-parameter value (lambda (stx) (error "not inside aif")))
(define-syntax (aif stx)
(syntax-case stx ()
[(_ test true false)
#'(let ([t test])
(syntax-parameterize ([value (lambda (_) #'t)])
(if t true false)))]))
(aif (regexp-match #rx"Hello" "Hello World!")
(display (car value))
(display "Failed!"))
Parsing infix arithmetic with Racket.
#lang racket
(require (for-syntax syntax/parse) racket/trace)
(begin-for-syntax
(define-syntax-class val
#:literals (+ - * /)
(pattern (~or x:id x:number)
#:attr value #'x)
(pattern (a:expr (~or o:* o:/ o:+ o:-) b:expr ...)
#:attr value #'(infix a o b ...))
(pattern (proc:id v:expr ...)
#:attr value #'(proc v ...))))
(trace-define-syntax (infix stx)
(syntax-parse stx
#:literals (+ - * /)
[(_ - v:expr) #'(- v)]
[(_ - a:val + v ...)
#'(+ (- a.value) (infix v ...))]
[(_ - a:val - v ...)
#'(+ (- a.value) (infix - v ...))]
[(_ - a:val v ...)
(with-syntax ([x (datum->syntax stx (gensym 'expr))])
#'(let-values (((x) (- a.value)))
(infix x v ...)))]
[(_ a:val + b:val v ...)
#'(+ a.value (infix b.value v ...))]
[(_ a:val - b:val v ...)
#'(+ a.value (infix - b.value v ...))]
[(_ a:val (~or o:* o:/) b:val + v ...)
#'(+ (o a.value b.value) (infix v ...))]
[(_ a:val (~or o:* o:/) b:val - v ...)
#'(+ (o a.value b.value) (infix - v ...))]
[(_ a:val (~or o:* o:/) b:val v ...)
(with-syntax ([x (datum->syntax stx (gensym 'expr))])
#'(let-values (((x) (o a.value b.value)))
(infix x v ...)))]
[(_ v:expr) #'v]))
(define x 4)
(infix - (cos 0) - (2 * 3 - x) - 3 * x / 5 + 6)
Your goal is to have a function where the input gets you a correct output according to the pattern.
For example:
- the input 5 should output 576
- the input 6 should output
Good luck!
SCROLL DOWN FOR HINTS
.
.
.
.
.
.
.
.
.
.
.
.
HINT #1:
-There is 1 multiplication symbol, and one pair of parenthesis (atleast, depending on the way you make the function)
HINT #2:
- The program can run in 1 line of code.
HINT #3:
- The input 15 gives an output of 1936
def pattern(n):
output = n[:]
return (output*2 + 14)**2
'''
READ:
- input 5 should output 576
- input 6 should output
'''
test.expect(int)
test.assert_equals(5, 576, "INCORRECT OUTPUT")
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
class Person
attr_accessor :name
def initialize(name)
@name = name
end
end
def change_name(new_name, thing)
if thing.respond_to?(:name=)
# do something
thing.name = new_name
else
nil
end
end
bob = Person.new("bob")
person_class = Person
number_three = 3
Test.assert_equals(change_name("Robert", bob), "Robert", "bob.name is set to Robert as attr_accessor creates :name and :name= methods")
Test.assert_equals(change_name("The Person Class", person_class), nil, "nil as Class doesn't have a name= method")
Test.assert_equals(change_name("Three", number_three), nil, "nil as 3 doesn't have a name= method")
The code should receive an input, and give out an output according to the assert equals tests, as described below.
Examples:
o 'hello' should output 'h tato'
o 'hello world' should output 'llo wollo wohello w tato'
o 'hello world!' should output 'llo worllo worhello wo tato'
o 'potato code test program.' should equal 'tato code test progrtato code test progrpotato code test prog tato'
HINT:
- It always ends with ' tato'
def PotatoCode(input):
output = input[2:len(input)-3]*2+str(input[:len(input)-4])+" tato"
return str(output)
# TODO: Replace examples and use TDD development by writing your own tests
# These are some of the methods available:
print("Potato Code: ")
test.expect(str)
test.assert_equals(PotatoCode("hello"), "h tato")
test.assert_equals(PotatoCode("hello world"), "llo wollo wohello w tato")
test.assert_equals(PotatoCode("hello world!"), "llo worllo worhello wo tato")
test.assert_equals(PotatoCode("potato code test program."),"tato code test progrtato code test progrpotato code test prog tato")
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings