The challenge for this month’s Exercise is to discover those values in the range 1 to 999 that have the highest number of factors. Never mind the math! Let C and the computer do the work for you.
Continue reading
Category Archives: Solution
Some Weighty Conversions – Solution
This month’s Exercise is to create a program that converts weight measurements by using this format:
nnnFT
Where nnn is a value, F is the unit to convert from, and T is the unit to convert to. This problem is more of an input-parsing exercise than a straight conversion.
Continue reading
Calculating Months – Solution
The task for this month’s Exercise is to return the month number for a time_t value. Effectively you extract the year and month, do some math, presto. Could it be this easy?
Continue reading
A Cumulative Total – Solution
I find it odd that the recursive solution for this month’s Exercise is far shorter than the non-recursive version. Yet, it has an elegance that’s evident in lots of recursive code examples.
Continue reading
Spelling Numbers – Solution
The task for this month’s Exercise is to write code that outputs strings for number values, 0 through 100. Your goal is to be clever with your solution, something that took me a few versions to get correct.
Continue reading
Multiples of Four – Solution
The solution this month’s Exercise isn’t that complex, but it was handy in disproving a theory.
Continue reading
Nested Processing – Solution
This month’s Exercise wasn’t astronomically difficult, but I did spend some time devising a solution. My goal was to try to avoid writing a nested loop. This goal proved unattainable.
Continue reading
Getting to Euler’s Number – Solution
The challenge for this month’s Exercise is not only to calculate Euler’s number, e, but to count how many loops a program must endure before your e value calculation matches the defined constant M_E. I hope you didn’t find this challenge too difficult.
Continue reading
Tic-Tac-Toe Evaluation – Solution
The insidious part of this month’s Exercise is writing a function that doesn’t count a stalemate as a win. It’s what happened to me for my first draft of a solution.
Continue reading
No Nines – Solution
The challenge for this month’s Exercise is to determine whether an integer, 1 to 100, is divisible by nine or contains the digit ‘9’. It seems like an easy puzzle for a C programmer to solve, but what I found interesting was crafting the output — specifically when a number both contains ‘9’ and is divisible by nine.
Continue reading