 # The Second 5 Coding Katas

My task to do 10 coding katas is finished. After seven “official katas” I invented my own assignments. Here are the first five coding katas. This post is a description of the second five katas:

#### Kata Yahtzee

Yahtzee is a game of dice. After rolling the dices you have to count the points. The assignment is to calculate the score for each possible category like ones, twos, one pair, two pair, small straight, full house and so on.
Here’s my C# solution on GitHub.

#### Kata Tennis

The task is to calculate the score of a tennis game in “tennis language” like “30-40”, “deuce”, or “advantage player1”.
Here’s my C# solution on GitHub.

#### Kata VeryLong

The assignment is to write code that can add, subtract, multiply, and divide very long integers. A useful algorithm as a starting point is to do the calculations how you would do the operations by hand on paper. To represent a number I chose a string and I performed the calculations in decimal. A variant would be to transform the numbers to binary and then calculate in binary. To speed up you can group several digits or bits together.
My C# solution is on GitHub.

#### Kata Pi

Calculate 1000 digits of pi (or 10’000’000 if you can). To do this you can start with VeryLong and expand it to use decimal separators as well. Then find a promising algorithm that converges quickly to pi. I tried several formulas:

• First I implemented Pi = 3 + 4/2/3/4 – 4/4/5/6 + 4/6/7/8 – 4/8/9/10 +-… (but it converges slowly)
• Then I implemented BBP puttygen download 615-544-4358 Telephone Area 201 , which converges a lot faster. Note that the point of BBP is to calculate a particular digit of pi without calculating its preceeding digits. So long number arithmetics is not actually required.
• My last implementation used one of the arcus tangens formulas.