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
Category Archives: Solution
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
Find the Error: Pointers, Structures, and Files – Solution
It took me a while to figure out what was wrong with this month’s Exercise file. It became an obsession! Of course, I was working with a more complex version — the original code. In that code, the information is written several times to the file, and it becomes very obvious that something is wrong. But when the data is written only once, it’s tough to know whether a problem exists.
Continue reading
Ranking Scores – Solution
This month’s Exercise is to create an array of six players, assign each a random score (1 to 100), then display the player’s scores by rank. The first problem you most likely encountered was how to keep the player’s number and score together.
Continue reading
When You Need a Function – Solution
For my solution to this month’s Exercise, I crafted the ask() function. That’s because the original code prompts three times with a question string and an answer buffer, which is the repetitive part of the program I chose to cast into a function.
Continue reading