How would you code the Look-and-Say sequence?

BTI360 Blog / July 15, 2014 in 

Yesterday we shared with you the code kata exercise we worked on during last week’s Code Kata Night.  Today, we will begin looking at some of the code our participants came up with for the Look-and-Say sequence beginning with java.  Take a look to see if this is how you would have coded it…

Test-Driven Even with Throw-Away Code:

One implementation written at the code kata event was produced by Chris.  Chris developed a regular expression implementation in Java that also uses recursion.  When we develop throw-away code in a short amount of time, we can be tempted to not be test-driven, or to not use JUnit, but rather put all of our code in the same basic implementation class, and test it with a “main” method.

Chris’ code, however, shows us why we don’t have to write code that way in order to have everything in one convenient place.  All of his code is in a test class, with an inner implementation class that contains the heart of the look-and-say sequence algorithm.

Check out Chris’ code…

Previous

Can you solve this code kata?

Next

How would you solve the Look-and-Say sequence with no strings attached?

Close Form

Enjoy our Blog?

Then stay up-to-date with our latest posts delivered right to your inbox.

  • This field is for validation purposes and should be left unchanged.

Or catch us on social media

Stay in Touch

Whether we’re honing our craft, hanging out with our team, or volunteering in the community, we invite you to keep tabs on us.

  • This field is for validation purposes and should be left unchanged.