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.

Find the maximum number

```
def find_max(arr):
return 0
```

```
# TODO: Replace examples and use TDD by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
test.assert_equals(find_max([1, 2, 3, 4, 5]), 5)
```

# Values of Data in Everyday Life

Software developers work with all kinds of data, produced by all kinds of people and processes. Medical records, food and drink sales, atmospheric condition, transportation patterns... these things all get produced from data.

## Going to the store

For example, imagine you make a trip to the grocery store this weekend. Here's what you buy.

- Four oranges
- One loaf of bread
- Two bags of chips
- One gallon of milk
- Three cans of tomato sauce

### Describing the Data

There are two ways to look at that data. First, you can describe the quantity of each thing you bought.

"I bought 4, 1, 2, 1, and 3 at the grocery store"

Of course, people would look at you funny. A better way would be to provide a label for what each of those numbers mean - which is how normal people talk.

"I bought 4 oranges, 1 loaf of bread, 2 bags of chips, 1 gallon of milk, and 3 cans of sauce.

An experienced software developer looks at that sentence very differently than you do. They see it as five, different data points about quantities. Each data point has two parts.

- The descriptive label for the quantity
- The quantity itself (i.e. the value of the quantity)

The labels are "oranges", "bread", "bags of chips", "milk", "tomato sauce".

The values are 4, 1, 2, 1, 3

## Second trip to the store

Two weeks later, you need to make another trip to the store. However, on this trip, the data is different. You buy the same things, but in different quantities because you know your sister is coming over for the weekend.

- Seven oranges
- Two loaves of bread
- Three bags of chips
- One gallon of milk
- Six cans of tomato sauce

Again, the labels are still "oranges", "bread", "bags of chips", "milk", "tomato sauce".

This time, though, the values are 7, 2, 3, 1, 6.

Each time you go to the store, the labels will remain the same, but the values attached to those labels varies. This are what developers use variables for. Words that human beings can read and understand (the label) which can be assigned a value.

## Your First Variables

Variables are labels for values that vary over time.

Time to see your first variables in JavaScript to represent the first trip to the store.

```
let oranges = 4
let breadLoaves = 1
let bagsOfChips = 2
let milk = 1
let tomatoSauce = 3
```

You use the keyword of `let`

to "declare a variable". In other words, it tells JavaScript that the word immediately to the right is going to be a variable. Then you type an equal sign, and then finally what value you want to be assigned to the variable.

You can make the variable name ANYTHING YOU WANT. You are the software developer, so you have that power. One thing that confuses many beginners is that they think the variable name matters. It doesn't. JavaScript doesn't care - at all - what your variables are. All it cares about is the values.

However, other developers do care what you name your variables. Imagine how frustrated you would be if instead of using the descriptive names above for the variables, you saw this code instead.

```
let o = 4
let bl = 1
let boc = 2
let m = 1
let ts = 3
```

The developer who wrote this code knew that "o" was an abbreviation for "oranges", but you would have no idea that it was. How annoying!

## Camel Case

Speaking of naming variables, it is a convention in the JavaScript developer community to name variables with camel case. This means that the variable starts with a lower-case letter, but each additional word in the variable name should start with a capital letter.

Bad variable naming

```
let bagofdonuts = 2
```

Good variable naming

```
let bagOfDonuts = 2
```

Good variable naming because it is a single word

```
let cucumbers = 3
```

Bad variable naming

```
let icecream = 1
```

Good variable naming

```
let iceCream = 1
```

## Changing a Variable's Value

Remember that the main purpose of a variable declared with `let`

is that the value varies. You can change the value assigned to all of the variables to reflect your second trip to the store.

```
oranges = 7
breadLoaves = 2
bagsOfChips = 3
milk = 1
tomatoSauce = 6
```

In case you didn't notice the difference, there is no `let`

keyword at the beginning of those lines of code. You are not declaring the variables any more. You already did that. This time you are changing the value of the variables.

## Adding the Values in Variables

In this introduction, the values for each of your variables are numbers. In this case, they are integers. The variables are placeholders, or labels, for those values. What this allows you to do is perform mathematical operations on the numbers by using the variables.

Look at the values for your first shopping trip again.

```
let oranges = 4
let breadLoaves = 1
let bagsOfChips = 2
let milk = 1
let tomatoSauce = 3
```

Now assume you want to know the total quantity of items that you bought at the store on that day. You can use the plus sign to add then all up.

```
const total = oranges + breadLoaves + bagsOfChips + milk + tomatoSauce
```

It looks weird to be adding words, but you need to remember that you're not adding the variables. You are adding the values that those variables represent. JavaScript interprets that code as the following.

```
const total = 4 + 1 + 2 + 1 + 3
```

Um, wait a second. What is that new keyword of `const`

?

It's short for "constant value". This means that you can't change the value of the variable you are declaring. If you try to, JavaScript will be angry with you. You can try this out for yourself. In the code editor, enter in the following two lines of code there, and click the "run >" button.

```
const bananas = 4
bananas = 10
```

You will immediately see an angry, red message in the console below it with the message

**SyntaxError: Assignment to constant variable: bananas**

- The
`let`

keyword for declaring variables will allow you to change the value. - The
`const`

keyword for declaring variables will not allow you to change the value.

Why would you choose `const`

instead of `let`

for the `totalQuantity`

variable? Well, that's a value that you don't want to be mistakenly change later in the code. Humans make mistakes all the time, and you don't want other code that you write to modify that total value.

## Your First Exercise

Now it is time for you to write your own code. Imagine that you want to determine what your electric bill costs are for an entire year. You gather all twelve electric bills in front of you and want to add them together. Instead of just entering in the numbers, you are going to assign those numbers as values to variables. Each variable will represent a single month's electric bill charge.

There is some code already provided for you in the editor to the right. Take a look...

```
const yearlyElectricCosts = () => {
let januaryBill = 43.11
}
```

Your job is to write eleven more variables to represent the charges for February, March, April, May, June, July, August, September, October, November, and December. Here are the charges that you need to assign to each variable.

- You spent 50.21 in February
- You spent 48.92 in March
- You spent 62.36 in April
- You spent 54.64 in May
- You spent 49.30 in June
- You spent 61.93 in July
- You spent 68.54 in August
- You spent 71.77 in September
- You spent 70.28 in October
- You spent 59.56 in November
- You spent 62.04 in December

After you have made all of your variables, declare one more at the end to store the total yearly charges. Remember that you can name the variable whatever you want.

Use the `const`

keyword to declare this variable instead of `let`

. You can name it anything you want, as long as it is descriptive. Here are some options, or you can choose your own.

- total
- yearlyTotal
- totalCharges

After you have added all of the numbers, you need to return the value of the variable. For example, if you chose `totalCharges`

as your variable name, the next line of code after you added everything should be...

```
return totalCharges
```

## Testing Your Code

Click the **Attempt** button in the lower-right corner of the screen any time your want to see if you got the code written correctly.

```
const yearlyElectricCosts = () => {
// Create 11 more variables with the correct values
let januaryBill = 43.11
// Decide on a variable name and add all the monthly charges
const
// Return the value of the variable by typing it in after the `return` keyword below
return
}
```

```
describe("Solution", function() {
it("should test for something", function() {
assert.strictEqual(yearlyElectricCosts(), 702.66)
});
});
```

Given an array with integers, remove numbers which are duplicated with previous or next sibling.

For example, with array [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3], the result should be [1, 3, 4, 9, 5, 3].

```
function kumite(arr) {
return [];
}
```

```
const expect = require("chai").expect;
describe("Solution", function() {
// it("should get [1, 3, 4, 9, 5, 3] when given [1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]", function() {
// const result = kumite([1, 3, 2, 2, 2, 4, 7, 7, 9, 5, 3]);
// expect(result).to.deep.equal([1, 3, 4, 9, 5, 3]);
// });
it("should get [] when given [1, 1, 2, 2, 2, 99, 99]", function() {
const result = kumite([1, 1, 2, 2, 2, 99, 99]);
expect(result).to.deep.equal([]);
});
});
```

Billy likes to keep all his number in an jar, however there's one special one that he likes to keep at the top of it. It turns out that Billy has accidentaly mixed up his jar, and he can't find his special number!

You must return a new array in which his special number is the first element. The arguments given to the function are as follows:

```
jar - All of Billy's numbers.
special - Billy's special number.
```

All original numbers in the resulting array must remain, it's only the order that's different.

If the array is empty or null, return `nil`

, `None`

, or `null`

. You can assume special is in the array.

```
def find_special(jar, special):
# initial solution
if jar != None and jar != []:
for i in range(len(jar)):
if jar[i] == special:
jar.insert(0,jar.pop(i))
break
return jar
return None
```

```
test.assert_equals(find_special([0, 5, 100, 9, 4], 9), [9, 0, 5, 100, 4])
test.assert_equals(find_special([], 3), None)
test.assert_equals(find_special([4, 5, 6.5, 99, 12.2, 46], 6.5), [6.5, 4, 5, 99, 12.2, 46])
test.assert_equals(find_special(None, 1), None)
test.assert_equals(find_special([3], 3), [3])
test.assert_equals(find_special([87, 5], 5), [5, 87])
```

Check given number, return true if it is an even number, otherwise return false.

For example isEven(3) will return false, isEven(4) will turn true.

```
function isEven(input) {
return true;
}
```

```
const expect = require("chai").expect;
describe("Solution", function() {
it("should be true for 4", function() {
expect(isEven(4)).to.equal(true);
});
});
```

```
puzzle = {0 : [0,0,0,0,0,0,0,0,0],
1 : [0,3,0,0,0,0,1,6,0],
2 : [0,6,7,0,3,5,0,0,4],
3 : [6,0,8,1,2,0,9,0,0],
4 : [0,9,0,0,8,0,0,3,0],
5 : [0,0,2,0,7,9,8,0,6],
6 : [8,0,0,6,9,0,3,5,0],
7 : [0,2,6,0,0,0,0,9,0],
8 : [0,0,0,0,0,0,0,0,0]
}
def makeGrid(puzzle):
for a in list(range(1,10)):
#print('Checking for: {}'.format(a))
grid = []
# Set block list
blockList = []
for x in puzzle:
row = []
y = 0
for n in puzzle[x]:
if n == a:
row.append(0)
blockList.append([x,y])
elif n != 0:
row.append(1)
else:
row.append(0)
y += 1
grid.append(row)
# Block using standard logic
for b in blockList:
grid = blockGrid(b, grid)
# Block using simplified dancing links (algorithm X) for fun
blockDLX(grid, a)
solveRow(grid, a)
solveColumn(grid, a)
def blockGrid(b, grid):
# Block row
x = b[0]
y = 0
for n in grid[x]:
grid[x][y] = 1
y += 1
# Block column
x = 0
y = b[1]
for row in grid:
grid[x][y] = 1
x += 1
# Block square
x = b[0]
y = b[1]
rowRange = [0,3,6]
columnRange = [0,3,6]
for a in rowRange:
if x >= a and x < a + 3:
for b in columnRange:
if y >= b and y < b + 3:
i = 0
while i < 3:
j = 0
while j < 3:
grid[a + i][b + j] = 1
j += 1
i += 1
return(grid)
def blockDLX(grid, a):
# Reduce rows
x = 0
subGrid = {}
for row in grid:
if row.count(0) != 0:
subGrid[x] = row
x += 1
# Reduce columns
for x in subGrid:
y = 0
solvedCount = 0
checkColumns = []
blockColumn = []
for n in subGrid[x]:
if n == 1:
check = 0
for row in subGrid:
if subGrid[row][y] == 1:
check += 1
if check != len(subGrid):
checkColumns.append(y)
else:
solvedCount += 1
else:
blockColumn.append(y)
y += 1
# Check columns
if len(checkColumns) > 0:
blockRow = []
for z in subGrid:
match = 'y'
for column in checkColumns:
if subGrid[z][column] == 0:
match = 'n'
if match == 'y':
blockRow.append(z)
if len(blockRow) == subGrid[x].count(0) and len(blockRow) != (len(subGrid[x]) - solvedCount):
for column in blockColumn:
x = 0
for row in grid:
if x not in blockRow:
grid[x][column] = 1
x += 1
def solveRow(grid, a):
x = 0
for row in grid:
if row.count(0) == 1:
y = 0
for n in grid[x]:
if n == 0:
#print('Match found x:{} y:{}'.format(x, y))
puzzle[x][y] = a
y += 1
x += 1
def solveColumn(grid, a):
y = 0
while y < 9:
column = []
for row in grid:
column.append(row[y])
if column.count(0) == 1:
x = 0
for n in column:
if n == 0:
#print('Match found x:{} y:{}'.format(x, y))
puzzle[x][y] = a
x += 1
y += 1
while any(0 in puzzle[row] for row in puzzle):
makeGrid(puzzle)
print('\n\nSolved:')
for x in puzzle:
print(puzzle[x])
```

```
# TODO: Replace examples and use TDD by writing your own tests
# These are some of the methods available:
# test.expect(boolean, [optional] message)
# test.assert_equals(actual, expected, [optional] message)
# test.assert_not_equals(actual, expected, [optional] message)
# You can use Test.describe and Test.it to write BDD style test groupings
```

What is the best way to list all divisors of a number?

A divisor of a number `n`

is another number `d`

where there is some number `k`

such that `n = d k`

In particular `1`

and `n`

are always divisors.

```
module Divisors where
divisors :: Integer -> [Integer]
divisors n = 1:n:(divisorsAux 2)
where
divisorsAux k
| (fromIntegral k) > sqrt (fromIntegral n) = []
| otherwise = if n `mod` k == 0
then if n`div`k ==k
then k:(divisorsAux (k+1))
else k:(n`div`k):(divisorsAux (k+1))
else divisorsAux (k+1)
```

```
module ExampleSpec where
import Test.Hspec
import Divisors
import Data.List
-- `spec` of type `Spec` must exist
spec :: Spec
spec = do
describe "divisorList" $ do
it "divisors of 5*4*3 = 60" $ do
(sort(divisors (5*4*3))) `shouldBe` [1,2,3,4,5,6,10,12,15,20,30,60]
it "divisors of 4" $ do
(sort(divisors 4)) `shouldBe` [1,2,4]
it "divisors of 5*3 = 15" $ do
(sort(divisors (5*3))) `shouldBe` [1,3,5,15]
it "divisors of 101" $ do
(sort(divisors 101)) `shouldBe` [1,101]
```

I want to show you task from Russian EGE exam

Given an array containing positive integers that do not exceed 15000. Find the number of even elements in the array that are not multiples of 3, replace all odd elements that are multiples of 3 with this number, and output the modified array. For example, for a source array of five elements 20, 89, 27, 92, 48, the program must output numbers 20, 89, 2, 92, 48.

```
using System;
public class RussianExam
{
public static int[] ExamTask(int[] array)
{
int count = 0;
for(int i = 0; i < array.Length; i++)
{
if (array[i] % 3 != 0 && array[i] % 2 == 0) count++;
}
for (int i = 0; i < array.Length; i++)
{
if (array[i] % 3 == 0 && array[i] % 2 != 0) array[i] = count;
}
return array;
}
}
```

```
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD by writing your own tests
[TestFixture]
public class SolutionTest
{
[Test]
public void MyTest()
{
int[] expected = new int[] { 20, 89, 2, 92, 48 };
int[] input = new int[] { 20, 89, 27, 92, 48 };
Assert.AreEqual(expected, RussianExam.ExamTask(input));
}
}
}
```

You need return the screen size on request

Find resolution can here:

[image]:https://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Vector_Video_Standards8.svg/1280px-Vector_Video_Standards8.svg.png

```
public string PrimitiveFlow(string s)
{
//Code here :3
return "";
}
```

```
namespace Solution {
using NUnit.Framework;
using System;
// TODO: Replace examples and use TDD by writing your own tests
[TestFixture]
public class SolutionTest
{
[ScreenTest]
public void ScreenResolution()
{
Assert.AreEqual("640 x 480", PrimitiveFlow("VGA"));
Assert.AreEqual("1280 x 720", PrimitiveFlow("HD 720"));
Assert.AreEqual("1280 x 800", PrimitiveFlow("WXGA"));
Assert.AreEqual("1920 x 1080", PrimitiveFlow("HD 1080"));
Assert.AreEqual("3440 x 1440", PrimitiveFlow("UWQHD"));
Assert.AreEqual("2560 x 1440", PrimitiveFlow("WQHD"));
Assert.AreEqual("2560 x 1080", PrimitiveFlow("UWHD"));
}
}
}
```

```
def numberplatereader(plate):
import re
if re.match("[A-Z]{2}[0-9]{2}\s[A-Z]{3}", plate) != None:
return True
else:
return False
```

```
Test.assert_equals(numberplatereader("KU63 NZZ"), True)
Test.assert_equals(numberplatereader("AB12 CDE"),True)
Test.assert_equals(numberplatereader("KU63 NZZ"), True)
Test.assert_equals(numberplatereader("12"),False)
Test.assert_equals(numberplatereader(""), False)
Test.assert_equals(numberplatereader("AB12 C0E"),False)
Test.assert_equals(numberplatereader("BDS 1"), False)
Test.assert_equals(numberplatereader("CBS 0"),False)
Test.assert_equals(numberplatereader("KV35 ZHE"), True)
Test.assert_equals(numberplatereader("BB12 BB8"),False)
```