Like many innocent and silly math games, No Nines is nerdy to play but fun to code. The game works like this:
Continue reading
Category Archives: Exercise
Dump That File!
One of the many, useful tools a programmer must have is a hexdump utility. The utility consumes a file’s raw bytes and outputs them in a human-readable manner. By examining the dump, you can determine if file contains the proper data in the correct format, as well as do other interesting, useful, and technerd things.
Continue reading
Automated Guessing Game
Last month, I published a post of the classic programming chestnut, a number-guessing game. In the post, I wrote: “Variable tries is set equal to 6 because I read somewhere that it’s possible to guess a value between 1 and 100 in six or fewer tries (though I’m probably incorrect).” And, yes, I was wrong.
Continue reading
Remove Trailing Blank Lines
Recently, I wrote a utility that required the final line of text in a file to terminate with a special code. The code had to sit at the end of a line of text, not on a blank line. What I discovered is that many text files end with one or more blank lines.
Continue reading
Morse Code Filter
I’m certain that the nerds would love debating whether the telegraph’s Morse code system was the first binary communications network. Let them do so. Still, Morse code remains a simple communications system, translating letters and numbers into dots and dashes — which you could argue are similar to ones and zeros.
Continue reading
The Yorn Function
When a computer program wants to know a Yes or No answer, the function I write is called yorn().
Continue reading
Know Your GPA
This semester has been brutal! You’ve had five classes, three of which are required for your major and two electives that turned out to be tougher than you anticipated. Yet, you pulled through the term without dropping a single course. You now have your grades and want to know your GPA for the semester.
Continue reading
Next Tuesday
What’s today?
The reply could be the day of a week, such as Sunday. That’s how I first answer the question. The more detailed answer is the day of the month, which isn’t often on my mind — unless it’s an important day like a birthday or some event.
Continue reading
Rotate the Grid
I’m not immersed in higher mathematics, therefore most of my programming puzzles tend to involve strings or other items I can easily comprehend. Beyond manipulating characters and strings, for my programming kung fu training I keep returning to the matrix or grid.
Continue reading
Write Your Own Integer Conversion
It’s not that programmers are lazy. Many professions involve a lot of copy-and-paste, borrowing stuff done before, re-purposing and re-using. Why re-invent the wheel? Still, doing so helps exercise your programming kung-fu as well as offers insights into how things work and why some operations are done the way they are.
As an example, consider the atoi() function.
Continue reading