Awesome Code Katas
I've been doing quite a few Code Katas, especially at Dallas Hack Club. Here is a list of code katas that you may want to try out. I recommend tackling them in the order they are listed :-).
- TOC
- Prime Factors - Rite of Passage
- Bowling Kata - Reinforcement
- Mars Rover - The Transition
- Poker Kata - Picking the Right Test
- Vending Machine Kata - Exploring Behaviors
- Map Kata - En Passe
- Conway's Game of Life
- Mancala
Map Kata - En Passe
This kata is a little tricky. You may come to a point where the solution you've created...has some problems (ie. the en passe).
Explanation
- Given a grid of arbitrary size
- Given a piece on this grid and given that piece can move an arbitrary number of spaces
- Provide all available squares the piece can move to (a piece cannot move diagonally)
A Piece starting 0,0 with a move radius of 2 on a 4x4 grid --------- | | | | | |x| | | | |x|x| | | |x|x|x| | --------- A Piece starting 3,3 with a move radius of 3 on a 7x7 grid --------------- | | | |x| | | | | | |x|x|x| | | | |x|x|x|x|x| | |x|x|x|x|x|x|x| | |x|x|x|x|x| | | | |x|x|x| | | | | | |x| | | | ---------------
The First En Passe
All done? Now add some hazards. A piece cannot move through a hazard.
A Piece starting 0,0 with a move radius of 2 on a 4x4 grid, a hazard located at 1,0 --------- | | | | | |x| | | | |x|x| | | |x|o| | | --------- A Piece starting 3,3 with a move radius of 4 on a 9x9 grid, a hazard located at 5,4 ------------------- | | | | |x| | | | | | | | |x|x|x| | | | | | |x|x|x|x|x| | | | |x|x|x|x|x|x|x| | |x|x|x|x|x|o|x| | | | |x|x|x|x|x|x|x| | | | |x|x|x|x|x| | | | | | |x|x|x| | | | | | | | |x| | | | | -------------------
The Next En Passe
All done? Now try a really large grid.
- Given a 100x100 grid and a piece starting at 0,0 and a move radius of 100
- The piece can move to all squares
- You may find that your solution runs too slowly
- Optimize your solution, good luck :-)
Written: 6/1/2012