When I see a problem such as finding a filename in a pathname, one of the first things I think of are regular expressions. For this month’s Exercise, however, that’s not the solution I coded.
Continue reading
Category Archives: Solution
Right String – Solution
For this month’s Exercise, I offer both a string function solution as well as a solution that uses pointers. As you can guess, I thought of the string method first, which is where most programmers would run to avoid the dratted topic of pointers.
Continue reading
The URL Decoding Filter – Solution
Unwinding percent-encoding involves three steps:
- Pass-through the unchanged characters.
- Change
+back into a space. - Decode the percent strings, which is the most involved process.
The URL Encoding Filter – Solution
A URL filter isn’t that difficult to code, once you know the rules. I’m sure you can concoct something clever or obfuscated in the C language, but I chose to use a clutch of if/else if/else statements to process input and generate output.
Continue reading
Change Due – Solution
I confess, the solution to this month’s Exercise was frustrating. Several times, I thought to abandon the premise and focus on the main problem, which is how to create a random price, such as $5.32, without that floating-point value really being 5.3187321.
Continue reading
The Perfect Shuffle – Solution
A perfect shuffle splits a deck of cards in two. The second half is folded evenly into the first half, so that every other card comes from the first and last half of the deck, respectively. This type of shuffle is practically impossible in real life, but for a computer simulation it’s not that difficult.
Continue reading
Day-of-the-Year Calculation – Solution
The solution for this month’s Exercise involves two steps. The first is to generate a random value from 1 to 365 (inclusive) as a day-of-the-year value. The second is to determine upon which month and day that value falls. That part may offer more difficulty than you anticipate.
Continue reading
Calculating the Date of Easter – Solution
Easter occurs later this month, on the 16th. You can discover that date by using Google or by running the code solution for this month’s Exercise.
Continue reading
Detailed Examination of a CSV File – Solution
The task for this month’s Exercise is to read a CSV file, store the data, then manipulate and report. For my solution, I chose to create an array of structures in which to store the weather information.
Continue reading
The CSV File – Solution
This month’s Exercise, required you to read a CSV file, extract specific information, and output a table. It’s basically a file-reading exercise, though you must also translate the input into the proper value. And you must output the month as a string.
Continue reading