# Code Kata nr. 3

So far we’ve had a credit card checking kata, another one on string manipulation, and now a tell-if-a-number-is-a-very-tricky-one. Its text, shortly is the following: given a number, return the FIBO-EMIRP number closest to it. Yeah, they actually are called FIBO-EMIRP. These numbers have the following properties:

• they are prime numbers
• the number’s reverse is also prime
• the number is not palindrome (*)
• the number is a fibonacci number (the fibonacci numbers: 1, 1, 2, 3, 5, 8, 13, 21 … Basically the i-th fibonacci number is given by the recursive formula f(i) = f(i-1) + f(i-2))

(*) It turns out that adding or removing this property does not have any effect on the final solution. Anyway, if you consider the kata too easy without it, just add the constraint; also, if you think it’s horribly hard, you can just ignore it.

Solving the kata (you can find it on my github page: https://github.com/tamasgyorfi/Code-kata—Fibo-Emirp-numbers) made it clear that two rounds of twenty minutes each would be enough. However, I did not take into account one important thing; the kata is not the best due to its character: a number has to be checked again and again and again against all the must-have properties. Putting together lots of different algorithms doesn’t make a good kata.

The goals of this kata were:

• clean code with self-explanatory names
• production code is added on red bar only refactoring is carried out on green bar only.

We also had an innovation this time, namely the introduction of infinitest (can be downloaded as an Eclipse plugin from http://infinitest.github.com/). Infinitest is a great automatic unit test running tool, that finds out which test cases are related to the source code being edited and runs them upon save. Such a way one can have a really fast feedback on the correctness of code. I’m looking forward to using it in our new project.

After the teams have solved the kata I’ve noticed a very important progress element: the guys were creating test cases step by step as described previously. Three weeks ago they were trying to write tests for the uppermost method, spending the whole time “in red”. Now, I’ve seen red and green bars alternatively which has made me glad ğŸ™‚

A lot of progress, go on folks!

## Author: tamasgyorfi

Senior software engineer, certified enterprise architect and certified Scrum master. Feel free to connect on Twitter: @tamasgyorfi