# Puzzles involving binary numbers

I teach third grade, and three times a week I take the high-performing math kids from the whole grade level and do an activity with them. Last week I introduced them to the idea of binary numbers. We did a Socratic dialog in which they puzzled out how a base-2 number system would work, including what the place values would be, and then I showed them how it related to powers of 2, and we talked about the use of binary in computer codes.

I showed them a few tricks with binary: how you can use it to guess a number between 1 and 1000 (really 1,024) in 10 guesses or fewer if the audience will tell you “higher” or “lower,” just by guessing each place value in turn (e.g., if your first guess is 512, you’re really asking whether, in base 2, there’s a 1 in the 9th place). I showed them how to guess a number between 1 and 100 just by asking whether the number was on 7 different cards, again by taking advantage of binary numbers/powers of 2. And I showed them the old trick about choosing between winning \$1,000 a day every day for 10 years, or getting a penny the first day and doubling it every day for thirty days.

They were amazed and delighted with all these tricks: it’s a group of kids ranging from competent to scary-bright, and I tried to keep the pace just a couple steps lower than what the scary-bright kids could do, which is much faster than what they usually get.

And now I’m almost out of tricks/puzzles for them, and I need enough for next week. I’d love to hear from y’all to see if you have some.

Here’s my last example, a puzzle from Car Talk some years ago that I finally solved when I thought of using binary:

If anyone has other puzzles or tricks that take advantage of binary or the powers of two, I’d love to hear them!

Not really a trick or puzzle (I’ll keep thinking of some, though), but now that you’ve introduced them, you could have them try to “see” where things are limited because a device is using a binary system (bytes) to manage the items.

For example, certain powers of 2 (indicating binary storage) pop all over the place in ads:

• 512 channels
• 64 different power settings
• “over 8192 different combinations”
So you could have them report when they see/hear of a binary stored value, and then tell you how many bits the device uses to store the value (512 = 9 bits, etc.)

Make a type of punched cards out of index cards. Use a reasonable number like 32 cards labeled 0 to 31. Put a set of holes close to the edge of one side of each card with a hole punch. Then use scissors to cut a notch out to the edge where the 0 bits would be. Now take a bicycle spoke (that’s what I used in the 5th grade) to pull a number out. For the binary number 10101 (21 decimal) put the spoke in the first hole (least significant bit) and shake out all the 0 cards and keep the ones on the spoke. Put the spoke in the second hole, shake out the 0 cards and keep those. I’m sure you can figure out the rest of the process to select a specific card. Next, shuffle the cars and sort them. Put the spoke in the first hole, shake out the 0 cards, and put them in front of all the 1 cards left on the stick (keeping the same order for the 0 cards you shake out). Repeat this for the other bits and the cards will be in order when you’re done. This is how data processing was done for decades before computers, and for a couple of decades afterwards as well.

These aren’t puzzles but are a few binary facts that you may be able to weave in to your teaching.

• Every power of 2 number has only ONE ‘1’ bit in its binary representation. E.g., 2 = b’10, 4 = b’100, 8 = b’1000, etc.

• Conversely, any number with more than one ‘1’ bit is NOT a power of 2.

• Mathematically, you can determine if any number ‘N’ is a power of 2 by using this expression:
if ((N & (N - 1)) == 0) then N is a power of 2 (where ‘&’ is the bitwise operator AND).

• A 10-bit binary number can represent 0 - 1023. A 20-bit binary number can represent 0 - 1048576. Or loosely, a 10-bit number is about 1000, a 20-bit number is about a million.

• Multiplication by 2 is simply adding a ‘0’ to the right side of the number. Or, saying it another way, multiplication by 2 is equal to left-shifting the number by 1.
Examples:
5 * 2 = 10 101 * 10 = 1010
13 * 2 = 26 1101 * 10 = 11010

• Conversely, integer division by 2 just removes one bit from the right hand side.
Examples:
12 / 2 = 6 1100 / 10 = 110
19 / 2 = 9 10011 / 10 = 1001

• For multiplying or dividing by powers of 2, just use the “power” as the number of bits to add or remove from the number.
Example:
10 * 8 = 80 1010 * 1000 = 1010000

j.

Not so much a puzzle but neat nevertheless. You start with a little triangle formed by 3 1’s. Like so:

``````

1
1 1

``````

The next row is constructed by binary addition of the two elements above each number. So through 5 rows:

``````

1
1 1
1 0 1
1 1 1 1
1 0 0 0 1

``````

This is equivalent to evaluating the parity of Pascal’s Triangle. If you do enough rows, you’ll notice a pattern appear, which is the Sierpinski triangle.

…ah, here it is!—complete with illustration.

He also describes the old chestnut with “mind-reading cards” (or “magic age trick” or “magic number trick”).

Hey that’s something, I had Martin Gardner beat by 20 years! But actually I think I read about this in Boy’s Life as a magic trick. I didn’t really understand the principles in the 5th grade. Later when I has to use punched sorters I realized what it was. I used to give an introduction to computers to high school students, back when understanding binary was important. This was a simple way to demonstrate some of the rudimentary things computers do, and how binary numbers fit into that scheme.

Anyway,** Left Hand**, I hope you use this. It’s got the hands on quality and the entertainment value that might get them interested.

Teach them to count to 1023 on their fingers.

You’re going to get in trouble when they get to 4, 128, and 132.

Waste a day letting the kids play Nim. Then show them how to find winning moves by writing the numbers in binary.

Towers of Hanoi require 2^n-1 moves for n rings. Have them solve a 3 or 4 ring puzzle then ask them to guess how long it would take to solve a 10 ring or 20 ring puzzle.

Dangit, my post was eaten. I think I’m actually going to take this in a slightly different, Nim-influenced direction, as all these very cool ideas are something I’m having trouble understanding, much less feeling confident about teaching to third-graders. I’m going to teach them about solvable games, starting with tic-tac-toe, and then moving into “100” (each player adds a number between 1 and 10 to a running total; the player that can say “100” wins), and have them work toward a solution for the game.

The Car Talk puzzle could be this one from May 2004: In Search of the Bogus Coins, a key part being “If one coin in the stack is counterfeit, they’re all counterfeit”. (2004 list of puzzles.)

That’s the one, and yes, when I say “one or more rolls of counterfeit coins,” I definitely mean that each roll contains either real coins or counterfeit coins but not both.

I played “Race to 100” today with them, and several of them almost instantly realized that you’d win the game if you said “89” (I said it during the example game I played with them–what can I say, I’m competitive), but nobody was able to backtrack from there to a perfect starting strategy. We’ll do that tomorrow, and then I might introduce Nim.

Couldn’t you take this many coins, say, from each pile: 1, 3, 5, 13, 25, 49, 97 ?

Looks good to me, but you took more than you have to. The binary solution is elegant for a couple of reasons: it’s the fewest possible coins to weigh, and it gives you the answer in a number that, converted to binary, tells you the number of the coin roll at fault.

But yeah, as long as you’re sure that each number is at least double the previous number, you’ll have a workable solution.

I remember doing the thing PacifistPorcupine mentioned on diamond shaped graph paper with various bases (not just binary) and then coloring in the numbers (all the 0s would be red, all the 1s blue) so that you could see the pattern.

And Towers of Hanoi & Nim, too.

Don’t forget 6, 384 and 390 for British students.

There’s a simple paper-and-pencil game called the “X Game”. It starts with various number of Xs written in rows. Two players take turns erasing Xs, and can erase as many as they want, but only from a single row and they must erase at least one X. The player who erases the last X wins.

The trick is to convert the number of Xs in each row to binary numbers. You then want to erase Xs to make the number of 1s in each place even.

For example, a typical starting grid is:

``````

X
XXX
XXXXX
XXXXXXX

``````

With the binary:

``````

X            1
XXX          11
XXXXX        101
XXXXXXX       111

``````

That’s already perfect: 2 1s in the fours place, 2 in the twos place, and 4 in the ones place. So, there’s no proper starting move … and you try not to go first. Your opponent does and it becomes, say:

``````

X            1
XXX          11
XXXXX        101
XXX        11

``````

The (unique) proper counter move is:

``````

X            1
XXX          11
X              1
XXX        11

``````

As long as you always end with an even number of 1s at each place, you will guarantee your win.

Greg Charles, that’s very similar to Nim, which septimus already mentioned. I like your explanation of how to solve the game–but can anyone explain why that solution works, in a simple narrative that I might be able to follow? (I can maybe try to convert that narrative into a third-grade friendly one, but I’ve been trying to understand why the solution works since I figured out how to implement it earlier this afternoon).