Friday Puzzler: Joes Car Wash

Today, Ray Camden posted Friday Puzzler: Joe's Car Wash and the Cheap Employee Problem to which I took up the challenge.

I wrote my solution as a CFC splitting each requirement into it's own method. Requirement A was to count the number of occurances of letters to make it easier for Joe's lazy employee to pick the right tiles to display on the sign. I assumed that Joe was so cheap he only owns upper case letters. I created a structure to contain each character used in the message looping through each letter in the message. The second requirement was to split the message into lines based on a specified width of the sign. Again, I created a structure, this time 1 item for each row. I grabbed text from the message for the length of the specified width, reversed the string, and then searched for the first occurance of a space. That resulted in the text for a single row, which I subtracted from the message and looped through until I had the final chunk of message shorter than the width.

Post a Comment
  1. Leave this field empty

Required Field

Rate this