Wednesday, February 5, 2014

Code Kata: toy fleet management

Background: there is an infinite grid with one point selected as a fleet management centre. There is a number (> 1) of cars that move through the grid, one step at a time, only in up, down, left and right directions. The cars periodically send their position on the grid to the management centre.

The task: we are to write a program that accepts coordinates sent by the cars and then can tell us the current total distance travelled by a car.

Points to consider: we assume that the coordinates are send periodically, regardless of the car's movement. Thus, a car may send various series of coordinates that our program must be able to interpret. Tip: the calculated total distance will be an approximation, not an exact value.

Additional functions (to be done as a next step, do not bring it outright into the design): if a car travels away from the management centre farther than N units, the program will signal that fact. Just use any method you wish to signal this, but remember that it should not be annoying, in case a driver took a long trip on the countryside.

Friday, December 20, 2013

Code Kata: A simple text-based calendar

In this Kata we want to properly display a simple calendar view of a given month. Let's start with an example. A proper output of our program for the input data of "December, 2013" would be:

Mo Tu We Th Fr Sa Su
                   1
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Points to consider:
  • how many times we need to make a call to time-date functions?
  • try to minimize the number of these calls
  • try to separate program logic from presentation as much as you can

Tuesday, August 6, 2013

Code Kata: A rover

Another game-like exercise. A rover moves over a board with X and Y dimensions. Some places on the board are filled with stones and this is where the rover cannot move onto. Your task is to implement the rover and the board with the following requirements and restrictions:
  • the rover understands your commands (e.g. from command line) of the form:
    • forward - moves one step forward
    • left, right - makes 90 degrees turn left or right
  • if the rover gets the forward command and there is a stone in front of it, it just ignores it; you can optionally print a message to signal that
  • the rover does not have the knowledge of the terrain - it keeps a reference to a board [object] which actually knows where the stones are and tells the rover whether a given move is possible or not
  • the rover should not be allowed to move outside of the board
Although it will probably be fun to test this with command line, you are encouraged to use TDD as you go.

See also