Feb 7, 2010

PPP: Alpha Counter

A Programing Practice Problem where the user provides a string and receives a single number back based on what each letter of the string is.

1) Alpha Counter

Provide me with a program that will satisfy the following curiosity. If each letter of the alphabet is represented by it's slot number, where A is 1, B is 2, and so on, what is the sum of the letters for your first name.

The program should take the name "Levi" and output 48. Any unrecognized chars shouldn't add anything to the total (such as the apostrophe in "O’Reilly" or the flem sound in Achmed").

2) Key'ed Alpha Counter

I recall going to lunch in second grade, and as a class being put in alphabetical order. With a last name of Watts, this was only enjoyed when we were in reverse order. To this end, this gives me another idea.

Add a means to our program to change the alphabet order with a key. Any letter not specified is added to the end in alphabetical order. For example, if we say "cat" then the three letters c, a and t are moved to the front, leaving the rest of the alphabet behind it. eg catbdefghijklmnopqrsuvwxyz

There is at least one sticky ambiguous decisions to be made. You are free to deal with it as you see fit, but document those choices. (If you are unsure what I speak of, I will be using my last name as a key to test your app.)

To see my implementation of this PPP, as well as a means to check your code's output, see my alpha counter. Use it as a means of checking your output, and point out any errors you find in my output. I'd hate for my errors to end up on prod.

No comments: