Angel \”Java\” Lopez on Blog

July 14, 2013

TDD Kata (6): Bulleyes

Previous Post
Next Post

At Google Code Jam, Round 1A, I found this problem:

https://code.google.com/codejam/contest/2418487/dashboard

The bull eyes problem: Mary should paint a series of concentric circle, given a radius and an initial amount of paint. The problem is: given r and t (the radius and the amount of paint) how many circles of width 1cm Mary can pain?

I wrote my solution using TDD, but after a first thoughts, I coded a solution using a formula, see:

https://github.com/ajlopez/TddOnTheRocks/tree/master/Bulleyes

The commit history at:

https://github.com/ajlopez/TddOnTheRocks/commits/master/Bulleyes

At the beginning, I had an algorithm that depended on a function that calculates the amount of paint needed to paint a circle of radius r. But then, I replaced it by other algorithm, that directly returns the count of circles that Mary can pain, given an initial radius and paint quantity. All my tests continued to be in green.

As in other Google Code Jam problems, I didn’t write the console program using TDD. I put my focus on the right algorithm. In this case, it was enough to have a general formula that solves the problem.

Keep tuned!

Angel “Java” Lopez
http://www.ajlopez.com
http://twitter.com/ajlopez

6 Comments »

  1. […] Previous Post Next Post […]

    Pingback by TDD Kata (5): Tree Search | Angel "Java" Lopez on Blog — July 14, 2013 @ 6:54 pm

  2. […] TDD Kata (6): Bulleyes […]

    Pingback by TDD Kata (6): Bulleyes | MVPs de LATAM — July 15, 2013 @ 5:52 pm

  3. […] Previous Post […]

    Pingback by TDD Kata (7): Manage your Energy | Angel "Java" Lopez on Blog — August 18, 2013 @ 10:36 pm

  4. First of all I want to say excellent blog! I had a quick question in which I’d like to ask if you don’t mind.
    I was interested to find out how you center yourself and clear
    your mind prior to writing. I have had difficulty clearing my thoughts in getting my thoughts out there.
    I truly do enjoy writing however it just seems like the first
    10 to 15 minutes are wasted simply just trying to figure
    out how to begin. Any recommendations or tips?
    Thank you!

    Comment by twitter followers no password free — September 1, 2013 @ 5:43 pm

  5. Write more, thats all I have to say. Literally, itt sedems as though you relied on the
    video to make your point. You definitely know wha youre talking about, why throw away your intelligence on just posting
    videos to your weblog when you could bbe giving us something informative to read?

    Comment by learn Spanish fast yahoo free kids game — November 28, 2013 @ 4:39 am

  6. Ahaa, its nice conversation regarding this article at this place at this blog, I
    have read all that, so at this time me also commenting here.

    Comment by ios — February 6, 2014 @ 1:54 pm


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: