Cyclops Numbers

Difficulty: ★ ★ ★ ☆

Oh, leave it to the propeller heads to devise a clever and fun name for something the rest of us never pay attention to. This time it’s a cyclops number, which is any decimal integer value with an odd number of digits and a big fat zero in the middle — like a cyclops’ eye.
Continue reading

The Elevator Ride

Difficulty: ★ ★ ★ ☆

I recently stayed at a resort with a tall hotel tower, over 30 stories. As I rode the elevator up to my floor, I thought about how the lift worked like a pointer traversing an array: The floors are elements. Each stop going up represents a passenger’s desired destination, as do stops on the return trip. My programmer brain was on fire!
Continue reading

Simplifying Fractions

Difficulty: ★ ★ ★ ☆

Recently, I wrote code to calculate odds. The program’s output listed the odds as a fraction, such as 1/6 for rolling a specific number on a die. But occasionally, the output is something like 7/21. As a human, and after a modicum of mental sweat, I recognize 7/21 as 1/3. The challenge is how to get the computer to recognize and report the smaller fraction.
Continue reading