NOTE: Code Kata #1 Follow-Up

February 7, 2012
By

This post was kindly contributed by NOTE: The blog of RTSL.eu - Development with SAS® - go there to comment and to read the full post.

A few weeks ago I published the first in an irregular series of code katas. In a previous post I had described code katas as a form of training for programmers.

I saw a lot of interest around the post.

Richard Koopman posted an elegant response on his blog, including an additional solution for US coinage. His solution was neat, making good use of arrays and iterative coding, but my attention was also caught by Richard’s home-made phone stand for his iPhone. Nice work Richard.

My old friend Dave Booth emailed me a solution that he had written off the top of his head, with no access to SAS at the time. It worked. I was suitably impressed. Dave’s solution, like Richard’s, used what Dave describes as a greedy algorithm. This is a very descriptive name and the Wikipedia entry offers the “coin change” challenge as an example. Dave also made a good point about handling errors elagantly:

Putting something in the code to try to trap unforeseen outcomes is a good habit to get into.

I agree, and code katas are a good opportunity to practice error trapping strategies.

Finally, Dave drew my attention to an excellent source of puzzles that could form code katas: ProjectEuler.net. The site offers a series of challenges that require a mixture of mathematical and computer science skills to solve. Take a look at the list of challenges and you’ll see some good starting problems such as “Add all the natural numbers below one thousand that are multiples of 3 or 5″.

In summary, don’t wait for me to post more code katas. There are plenty out there on the web, and they all offer great opportunities for you to improve your coding skills.

This post was kindly contributed by NOTE: The blog of RTSL.eu - Development with SAS® - go there to comment and to read the full post.

Tags: ,

Proc-x is looking for sponsors!

Dear readers, proc-x is looking for sponsors who would be willing to support the site in exchange for banner ads in the right sidebar of the site. If you are interested, please e-mail me at: [email protected]

Welcome!

SAS-X.com offers news and tutorials about the various SAS® software packages, contributed by bloggers. You are welcome to subscribe to e-mail updates, or add your SAS-blog to the site.

SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration.