The three units of weight I’m familiar with are pounds, kilograms, and stone. For me, stone is the odd one. I’ve heard it used in Britain and it’s completely baffling to me, often requiring that I whip out a calculator to see what “14 stone” really means. Better, I could write code that converts between pounds, kilograms, and stone, which is the goal of this month’s Exercise.
Continue reading
Author Archives: dgookin
The Chicken McNuggets Problem

Chicken McNuggets come several to a box, depending on what you order: six pieces for a kid, nine pieces for an adult, or twenty pieces for an honest adult. These numbers in various combinations form what the math nerds call McNugget Numbers.
Continue reading
The Golden Ratio – Recursion Version
Oh, how I distrusted recursion when I was a budding programmer. It’s just a tough concept to wrap your head around, especially if you’re an old warhorse Assembly programmer like me who lives in fear of blowing up the stack. Trivial asides aside, recursion often presents an elegant and efficient way to solve a programming puzzle.
Continue reading
The Golden Ratio
Like many other mathematical delights, the golden ratio pops up all over. It has a rich history, and a special Greek letter to represent it: φ phi. The value is irrational, meaning it cannot be expressed as a ratio of two integers: 1.6180339…
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
More Efficient Prime Number Calculations
A long time ago, I looked at one of my prime number hunting programs, such as the one demonstrated in last week’s Lesson. I thought, “How can I make this program more efficient?” It’s something all programmers should do.
Continue reading
Calculating Months
I recently updated my Wambooli website’s front page to show only recent blog posts. I don’t regularly maintain the Wamblog any longer, so it was disappointing for me to see “recent posts” from ages ago. Therefore, I did a little coding to ensure that only recent posts appear or nothing.
Continue reading
Generating Prime Numbers
Numbers with only two factors, one and themselves, are prime. One way to discover which numbers are prime in a computer program is to plow through all the factors.
Continue reading
A Matter of Factors
Prime numbers are a popular topic in computer programming. It surprised me that I hadn’t yet plumbed primes on this blog, so I’m past due. And forget about the nerdy aspect of prime numbers. Of all the concepts in mathematics, primes are something most people understand.
Continue reading
String Versions of ctype Functions
The ctype functions are marvelous for single character manipulation and testing. Often, however, the functions appear in a loop so that they can be applied to an entire string. So why not write a string-based ctype function? Of course, that’s what I did.
Continue reading