A Solution for 100 Doors

When I code a program, I start out by slapping together the various elements. I setup the variables, I write some quick routines, and I add comments to the tune of /* Do something here*/. With those bricks in place, I go back and fill in the mortar to make it all work. If the code runs, great! That rarely happens, so more work is involved.
Continue reading

Find the Best Size Container

Not everything in the real world appreciates the holy computer numbers. These are binary values that parallel the powers of 2: 1, 2, 4, 8, 16, 32, 64, and so on.

A common computer puzzle is how to allocate storage specific to those holy numbers, especially when the sizes of items that you’re working with don’t exactly line up to a specific holy computer number.
Continue reading

The Problem of 100 Doors

Plenty of interesting and fun programming puzzles are available to test your skills. Some of these puzzles come from the realm of mathematics or logic. What those propellerheads do with the solutions is up to them, but often you can code such problems to help you learn more about programming. One such logic problem is called 100 Doors.
Continue reading

Off to the Races!

Computer games were simple back in the early days. Output was printed on a teletype or displayed on a text-only CRT. Input wasn’t interactive or real-time. These games were fun to play back then, but are kind of lame now. They still exist with regards to simple programming exercises. In fact, you can pound out a older type computer game in a few minutes if you know the basics of the C language.
Continue reading

Wide Bit Fields

An on-off bit field is pretty common; you’ll find them all over. Also common are wide bit fields, which can hold values greater than one or zero. These wide bit fields are often mixed with single-bit fields making for a wonderful stew of binary data all held within a single integer value.
Continue reading