The most difficult thing about this month’s Exercise is to deal with stream input: When the user overstuffs the input buffer, those extra characters continue to flow into the program, interpreted as additional input and they make the output look ugly.
Continue reading
Category Archives: Solution
Know Your GPA – Solution
It’s fun supplying your own scores for a semester, which really helps boost your GPA! Still, the challenge for this Month’s Exercise was to input — and validate — a series of grades to calculate your GPA for five courses.
Continue reading
Next Tuesday – Solution
One way to discover next Tuesday’s date is just to wait. You could code that solution in C, which would be silly, but I hope that you instead chose to use some time functions to derive your answer.
Continue reading
Rotate the Grid – Solution
The challenge for this month’s Exercise is to fill a grid with random letters, a to z, then rotate that grid on its side, counterclockwise, and display the results. Such fun.
Continue reading
Write Your Own Integer Conversion – Solution
This month’s Exercise is to emulate the antique atoi() function, which converts a string of digits into an integer value.
Continue reading
Parse and Count Words in a String – Solution
The key to making this month’s Exercise work isn’t to know when a word stops, but when the separator characters stop. That’s because words aren’t always separated by single characters.
Continue reading
Primitive Math – Solution
The solution to this month’s Exercise involves two things. First, knowing how to shift bits and second how to carefully enclose operators in parentheses to get the macros to behave.
Continue reading
Interesting Numbers – Solution
Interesting numbers have a mathematical property that makes them handy in a certain way. For programming, these numbers present useful binary patterns that may be obvious in hexadecimal but meaningless in decimal. For non-programmers and non-mathematicians, interesting numbers offer visual patterns that most likely have no useful application beyond their look.
Continue reading
Find the Duplicates – Solution
I devised two solutions for this month’s Exercise. The basic solution can be solved in two steps, with a more involved solution using three.
Continue reading
The Wandering King – Solution
This month’s Exercise was inspired by a program I recall from years ago called The Drunk and the Lamppost. It’s not the classic joke, but an examination of random movements and probability.
Continue reading