Sep 24, 2012

Code Kata Rutt

So Michael Ferante talked me into trying the daily routine of a Code Kata. I was looking for two things: to learn something, and perhaps to find a programming problem suitable for a pairing exercise.

I did learn some things about Ruby: String#each_char, Heredocs (and that they can't be embedded in a single-statement Hash), and the syntax for up-to-but-not-including in ranges.

What I've found is that after three attempts I've incorporated a couple of good ideas, but I'm not going to arrive at a better solution. Does that mean I've picked too simple a problem?

My problem is also bad as a pairing exercise. I only arrive at two tests with the last test resulting in having to write the majority of the code. That would have for very dull ping-pong pairing. Again, did I pick the wrong problem?

Here's my code kata repo.

The exercise is to take a number and print it using this font - excerpt:

 .d8888b.  d888   .d8888b.  .d8888b.  ...
d88P  Y88bd8888  d88P  Y88bd88P  Y88b ...
888    888  888         888     .d88P ...
888    888  888       .d88P    8888"  ...
888    888  888   .od888P"      "Y8b. ...
888    888  888  d88P"     888    888 ...
Y88b  d88P  888  888"      Y88b  d88P ...
 "Y8888P" 8888888888888888  "Y8888P"  ...  
Edit: For a tougher challenge, try this font: (note that the space is used more aggressively -- compare 4 vs 45 and 1 vs 01)
 ____________  ________     _____ .________ _________________  ______  
/_   \_____  \ \_____  \   /  |  ||   ____//  _____/\______  \/  __  \ 
 |   |/  ____/   _(__  <  /   |  ||____  \/   __  \     /    />      < 
 |   /       \  /       \/    ^   /       \  |__\  \   /    //   --   \
 |___\_______ \/______  /\____   /______  /\_____  /  /____/ \______  /
             \/       \/      |__|      \/       \/                 \/ 

No comments: