I don’t believe one definitive solution exists for this month’s Exercise: Output a string of upper- and lowercase letters. No, the challenge is more to discover different insights a coder has to a specific problem.
Continue reading
Category Archives: Solution
Your Own Version of left-pad() – Solution
Can you write your own left-pad function in C? Would you get so angry that you’d pull it from the Jenga-tower NPM and bring the Internet to its knees? I hope your answer Yes to the first question and No to the second, because your task for this month’s Exercise is to write that function.
Continue reading
The Elevator Ride – Solution
To code a simulated elevator ride you must know the floor requests, up and down. This is the challenge given for this month’s Exercise, which can either drive you nuts or delight you depending on how you craft your solution.
Continue reading
Splitting a Decimal Value – Solution
Cleaving a decimal value into its integer and fractional portions is a neat trick, one that relies upon C natural capability to thwack off the decimal portion of a float when it’s recast as an integer. Knowing about this conversion makes solving this month’s Exercise a whole lot easier.
Continue reading
The Babylonian Square Root – Solution
I was blown away by the elegance and simplicity of the Babylonian Method to calculate a square root, which is the topic of this month’s Exercise. I only hope that my solution lives up the challenge, lest I suffer the fate of the Assyrians.
Continue reading
Simplifying Fractions – Solution
This month’s Exercise both terrified and enticed me. Yes, I code these solutions myself after I think up the challenges. No cheating here! This particular puzzle was more fun than I imagined, but also required a lot of mental work.
Continue reading
The Microwave Problem – Solution
The challenge for this month’s Exercise is to write a microwave oven input routine: The user types in a given number of seconds and your program translates the value into the proper number of hours, minutes, and seconds. This type of problem may sound familiar.
Continue reading
Decoding a String – Solution
Encoding means nothing if you can’t decode, which is the task for this month’s Exercise: Transform the encoded hex bytes back into characters, unwinding the formula used to create them. The challenge isn’t really as much with coding the math as it is with translating hex bytes back into integer values — characters.
Continue reading
Encoding a String – Solution
The task for this month’s Exercise is to write an encoding filter that follows a specific pattern: After the first character (or byte) is output as a 2-digit hex value, the remaining characters are output as the difference between the previous character and the current character. I’m sure this type of encoding has an official name, but it’s the holidays and I’m too lazy to look it up.
Continue reading
The Power Grid – Solution
I hope you didn’t find this month’s Exercise too difficult. I do occasionally like to toss in an easy one. But for me, the big task was getting the output just right.
Continue reading