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
Category Archives: Exercise
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
Parse and Count Words in a String
This month’s Exercise is based on code presented in the June 1 Lesson: split a string into separate words. The difference is that each word you pluck from the string is followed by the number of letters in that word.
Continue reading
Primitive Math
In a recent Lesson, I explored upon the idea of creating binary math macros. This technique was popular in Assembly language programs where the processor lacks high order math functions, including basic multiplication and division. In C you can code one-line macros that mimic Assembly’s bit-shifting behavior required to multiply values.
Continue reading
Interesting Numbers
Long ago, I worked with a programmer who had a habit of referring to certain values as “interesting.” What was an interesting number to him? 43,690. Yeah, it seems dull, but in hex it’s 0xAAAA
and in binary it’s 1010101010101010
. Interesting.
Continue reading
Find the Duplicates
You’ll find multiple reasons to remove duplicates from a series of random numbers. The main reason is that the process or generating random numbers is capable of yielding duplicate values. But more importantly, if your list represents discrete items in the real world, such as playing cards, you can’t really have a duplicate value pop up.
Continue reading