## Saturday, April 22, 2017

### Marking a Ruler

A 13-inch ruler only needs four markings on it so that it can be used to measure any whole number of inches from 1 to 13. At what positions should the four markings be? (Do not include the two ends, which are understood to be markings 0 and 13.) Click below to see the answer.

Labels:
brain teasers,
puzzles

## Saturday, April 15, 2017

### Move One Digit

The following equation is incorrect. Can you make the equation balanced by moving only a single digit?

101 - 102 = 1

Click below to see the answer.

The digit that needs to be moved is the 2. Just move it up into the exponent and the equation is correct.

101 - 10

101 - 10

^{2}= 1## Saturday, April 8, 2017

### What is the next number in the sequence?

Without Googling it, can you tell me the next number in the following sequence?

1

11

21

1211

111221

312211

13112221

1113213211

That should be enough to see the pattern, but this sequence goes on infinitely. Click below to see the answer.

This sequence is known as the "Look and Say" or "Say What You see" sequence. Each term is formed by describing the previous term. The first term is just the digit 1. To describe it you would say "one one," so the next term is 11. To describe that you'd say "two one," and so on. The next term after the ones shown is 31131211131221. Check the Online Encyclopedia of Integer Sequences (A005150) for more terms following that.

## Saturday, April 1, 2017

### Beer Run

A man runs

*laps around a circular track with a radius of*

**n***miles. He says he will drink*

**t***quarts of beer for every mile he runs. How many quarts will he drink? Click below for the answer.*

**s**He will only need one quart, no matter how far he runs. If the radius of the track is

*miles, then the circumference is 2*pi*t miles. The man will run***t***laps, so the total distance is 2*pi*n*t miles. If he drinks***n***quarts per mile, then the total amount of beer is 2*pi*n*t*s, which equals one quart!***s**## Saturday, March 25, 2017

### 10-digit Number

Find a 10-digit number where the first digit is how many 0's there are in the number, the second digit is how many 1's in the number, the third digit is how many 2's, and so on, until the tenth digit which is how many 9's there are in the number.

Click below to see the answer.

As a programmer, I'm often tempted to try to use a brute force approach to find the answers to number puzzles. That often works, but when brute force involves looping through all 10-digit numbers, you should probably look for a more elegant approach.

Let's see if we can construct the solution using logic instead. We can't have 0 zeroes, because then we would have to put 0 in the zeroes digit, and it would immediately be wrong. I'll start with a 9 in the zeros digit and the rest zeros, then make corrections until we hit on a solution.

90000 00000

Now we have a 9, so there should also be a 1 in the 9 column.

90000 00001

But now there aren't 9 zeroes, there are only 8. There's also a 1, which means we have to change the first and second digits.

81000 00001

Wait, now there isn't a 9, so we have to move that last 1 over. There are also two 1's, so we have to change the second digit.

82000 00010

That's closer, but now there is a 2, so we have to record it in the twos column. There are also fewer 0's, so we have to change the first digit as well.

72100 00010

Still not quite right. There are now only six 0's, so we have to change the first digit again. There's also no longer an 8. We can make both of these changes at once, giving us a final answer of

62100 01000

Let's see if we can construct the solution using logic instead. We can't have 0 zeroes, because then we would have to put 0 in the zeroes digit, and it would immediately be wrong. I'll start with a 9 in the zeros digit and the rest zeros, then make corrections until we hit on a solution.

90000 00000

Now we have a 9, so there should also be a 1 in the 9 column.

90000 00001

But now there aren't 9 zeroes, there are only 8. There's also a 1, which means we have to change the first and second digits.

81000 00001

Wait, now there isn't a 9, so we have to move that last 1 over. There are also two 1's, so we have to change the second digit.

82000 00010

That's closer, but now there is a 2, so we have to record it in the twos column. There are also fewer 0's, so we have to change the first digit as well.

72100 00010

Still not quite right. There are now only six 0's, so we have to change the first digit again. There's also no longer an 8. We can make both of these changes at once, giving us a final answer of

62100 01000

## Saturday, March 18, 2017

### The Extra Dollar

Here is an old math puzzle that you can find many versions of online.

Two friends have a meal at a restaurant, and the bill is $25. The friends pay $15 each, which the waiter gives to the cashier. The cashier gives back $5 to the waiter. The friends tell the waiter to keeps $3 as a tip, so he hands back $1 to each of the two diners.

So, the friends paid $14 each for the meal, for a total of $28. The waiter kept $3, and that makes $31. Where did the extra dollar come from? Give yourself a moment to think about it before clicking below for the solution.

$25 is sitting with the cashier, $2 is back with the diners, and $3 is with the waiter. That adds to the required $30, so there really is no extra dollar.

The mistake is expecting that what the diners paid and what the waiter kept to add up to what they initially gave. Adding $28 and $3 is just a bit of sleight-of-hand. It's the amount that the meal effectively cost them (including tip), plus the amount they received back, that should add to $30.

The mistake is expecting that what the diners paid and what the waiter kept to add up to what they initially gave. Adding $28 and $3 is just a bit of sleight-of-hand. It's the amount that the meal effectively cost them (including tip), plus the amount they received back, that should add to $30.

Labels:
logic puzzles,
numbers

## Saturday, March 11, 2017

### Arranging Eights

Can you arrange eight 8's so that when added they will equal 1000? Click below to see the answer.

It's certainly possible to try all 22 different ways to partition eight identical digits, but there is a shortcut.

All of the numbers that are created by arranging eight 8's will end in the digit 8, and the sum of the last digits of those numbers must be a multiple of 10 (because the target sum of 1000 ends in 0), so we know there must be exactly five groups of digits in the correct solution. That means we only have to check 3 different partitions of the eight digits.

8888 + 8 + 8 + 8 + 8

888 + 88 + 8 + 8 + 8

88 + 88 + 88 + 8 + 8

These are the only three ways to partition eight identical objects into five groups, and they are the only groupings whose sums end in the digit 0. You can check with quick mental arithmetic that the second grouping is the correct solution.

All of the numbers that are created by arranging eight 8's will end in the digit 8, and the sum of the last digits of those numbers must be a multiple of 10 (because the target sum of 1000 ends in 0), so we know there must be exactly five groups of digits in the correct solution. That means we only have to check 3 different partitions of the eight digits.

8888 + 8 + 8 + 8 + 8

888 + 88 + 8 + 8 + 8

88 + 88 + 88 + 8 + 8

These are the only three ways to partition eight identical objects into five groups, and they are the only groupings whose sums end in the digit 0. You can check with quick mental arithmetic that the second grouping is the correct solution.

## Saturday, March 4, 2017

### A Unique Number

What is unique about the number 8,549,176,320? Click below to see the answer (and a bonus question).

There's nothing

*numerically*particularly unique or interesting about the number above. It is made up of all of the digits from 0 to 9, but a lot of numbers have that property. The unique thing about this number is that all of the digits from 0 to 9 are in alphabetical order when spelled out in English.**Bonus question:**Can you think of a number whose letters when spelled out in English are all in alphabetical order? Example: The first three letters of the word "five" are in alphabetical order, but the "e" at the end spoils it.
Labels:
brain teasers,
numbers,
puzzles

## Saturday, February 25, 2017

### Best Poker Hand

Which of the following poker hands is the best? Assume one standard 52-card deck is used. The game is five-card draw, so there are no community cards, with no wild cards.

For reference, here are the rankings of poker hands.

**Royal flush**- A, K, Q, J, 10, all the same suit.**Straight flush**- Five cards in a sequence, all the same suit.**Four of a kind**- Four cards all of the same rank.**Full house**- Three of a kind with a side pair.**Flush**- Any five cards, all the same suit**Straight**- Five cards in a sequence, any suits.**Three of a kind**- Three cards all of the same rank.**Two pair**- Two different pairs.**One pair**- Two cards of the same rank.**High card**- Highest card in your hand.

Click below to see the answer.

Hand #1 is the highest-ranking hand shown, but since all of these hands cannot occur on the same deal, it isn't the best hand to have in a real game.

To determine which hand is

To determine which hand is

*best*, you have to look at how many other hands can beat each hand when dealt from the same deck. All of the hands above can be beaten by the same number of four-of-a-kinds, but by different numbers of straight flushes. Having two sixes as your side pair breaks up more of these possible straight flushes than having two kings, so hand #4 is actually the best hand to have. (There are 32 possible straight flushes that beat the kings hand, but only 24 that beat the sixes.)
Labels:
brain teasers,
logic,
puzzles

## Saturday, February 18, 2017

### The Collapsing Bridge

The bridge will collapse in 17 minutes! Four people need to cross the bridge before it collapses. It is a dark night and they have only one flashlight among them.

Only

**two people**can cross at a time.

- Alice takes one minute to cross.
- Bob takes two minutes.
- Carol takes five minutes
- Dave takes 10 minutes to cross.

The trick to this puzzle is to get the slowest members of the group to cross only once together, while the fastest members cross back and forth multiple times.

- Alice and Bob cross first using up 2 minutes.
- Alice comes back making it 3.
- Carol and Dave cross together making it 13 minutes.
- Then Bob crosses back, making it 15 minutes.
- Finally, Alice and Bob cross together to make it a total of 17 minutes.

Labels:
brain teasers,
logic puzzles,
math

## Friday, February 10, 2017

### The Island of Knights and Knaves

Raymond Smullyan, one of the grand masters of logic puzzles, sadly passed away at the age of 97 earlier this week. In his honor, I present a classic puzzle adapted from his book What Is the Name of This Book?

There is a wide variety of puzzles about an island in which certain inhabitants called "knights" always tell the truth and others called "knaves" always lie. It is assumed that every inhabitant of the island is either a knight or a knave.

In this problem, there are only two people, A and B, each of whom is either a knight or a knave. A makes the following statement: "At least one of us is a knave." What are A and B?

Click below for the solution.

The solutions to these puzzles are often found by making one or more assumptions, then reasoning out whether or not it can be true. In this case, assume A is a knave. Then the statement "At least one of us is a knave" would be false, since knaves always lie. Hence, both A and B would be knights, which is impossible because we started with the assumption that A is a knave. Therefore, A must be a knight, and the statement "At least one of us is a knave" must be true, and B is a knave.

Raymond Smullyan presented a couple more of his puzzles in a 1982 interview on the Tonight Show with Johnny Carson. When you see the white hair and long beard, it seems like even 35 years ago that Smullyan was an old man, but the twinkle in his eye and the playfulness in his voice reveal that he was always a child at heart. Watch the full interview below.

If these puzzles seem too easy, they're just a small sample of Dr. Smullyan's brilliant work. If you really want a challenge, I encourage you to check out some of his books, or The Hardest Logic Puzzle Ever, also credited to Smullyan.

Finally, I leave you with a quote.

Why should I be worried about dying?

It's not going to happen in my lifetime!

-Raymond Smullyan (1919 - 2017)

Labels:
logic puzzles,
smullyan

## Saturday, February 4, 2017

### Animal Kingdom

What do the following animals all have in common?

- firefly
- jackrabbit
- koala bear
- prairie dog
- silkworm
- guinea pig

Click below to see the answer.

All of the animals listed above are impostors.

- The firefly is not a fly. It is a beetle.
- The jackrabbit is not a rabbit. It is a hare.
- The koala is not a bear. It is a marsupial.
- The prairie dog is not a dog. It is a rodent.
- The silkworm is not a worm. It is a caterpillar.
- The guinea pig is not a pig. It is a rodent. (And it's not even from Guinea, a country on the west coast of Africa. Guinea pigs originated in the Andes mountains in South America.)

Labels:
brain teasers,
puzzles

## Saturday, January 28, 2017

### Name this Book

When this book first came out, it was only read by a handful of rather wealthy people. Now almost everyone has a copy, and many people read it regularly. You cannot buy it from a bookstore or borrow it from the library. Can you name this book? Click below for the answer.

It's a phone book.

This is a good example of an old riddle that has not aged well, so don't feel bad if you found it a bit tricky. Newer technology has rendered phone books practically useless, yet I still get one delivered to my house every year. In another generation or so, many people might not know what they were used for.

This is a good example of an old riddle that has not aged well, so don't feel bad if you found it a bit tricky. Newer technology has rendered phone books practically useless, yet I still get one delivered to my house every year. In another generation or so, many people might not know what they were used for.

Labels:
brain teasers,
puzzles,
riddles

## Saturday, January 21, 2017

### The Brodie Helmet

At the outbreak of World War I, none of the combatant nations provided steel helmets to their troops. Soldiers of most nations went into battle wearing cloth or leather hats that offered little protection from modern weapons. As a result, many soldiers suffered head injuries from exploding shrapnel.

In April of 1916, British soldiers began using a metal helmet in battle called the Brodie helmet, but authorities discovered that the proportion of head injuries then

*increased*. Why should the incidence of head injuries increase when soldiers wore metal helmets rather than cloth caps? Click below to see the answer.

The number of recorded head injuries did increase after the introduction of the Brodie helmet, but the number of deaths

*decreased*. Prior to the introduction of metal helmets, if a soldier were hit in the head with a piece of shrapnel, it would have likely killed him. This would have been recorded as a death, not a head injury. More head injuries were recorded after the helmets were introduced due to the simple fact that more soldiers were surviving them.## Saturday, January 14, 2017

### Panama Canal

A ship sailed through the Panama Canal going from west to east. When it exited the canal, it entered the Pacific Ocean. (The ship did not double back.) How can this be so? Click below to see the answer.

Normally when we think about the American continents, we think of the Pacific Ocean being to the west and the Atlantic Ocean to the east, but that isn't strictly the case. Panama is an isthmus that curves, and the Panama Canal was constructed so that it runs from the Caribbean Sea on the northwest end to the Pacific Ocean on the southeast. In the age of instant access to world maps, this "puzzle" is probably a lot easier to verify now than when the canal was originally built.

## Saturday, January 7, 2017

### Rope Around the Earth

Suppose you tie a rope tightly around the Earth at the equator. (Assume the Earth is perfectly spherical, and that the surface is smooth so that the rope lies tight against the surface at all points.) Now suppose that you add an additional 6 feet to the length of the rope. How high off the surface would the rope lie? You could look up the Earth's circumference and do the math to come up with an exact answer, but can you quickly come up with an intuitive guess? (High enough to slide a piece of paper under? To wave your hand under? To walk under?) Click below to see a hint or the answer.

**Hint:**If I reversed the parameters and told you that I increased the length enough to raise the rope 6 feet from the surface in all directions, could you tell me how much was added to the length of the rope? (Given the formula for the circumference of a circle, C = 2Ď€r, but not knowing the circumference of the Earth, can you come up with a guess?) Reversing that, can you come up with the answer to the original problem?

**Answer:**The first time they hear this puzzle, many people will try to do the math starting with the circumference of the Earth. That doesn't matter though. It's a property of any circle that if you increase the circumference by a fixed amount, the radius will change by that amount divided by 2Ď€ (because r = C/2Ď€). The rope could be tied around a beach ball or a tennis ball and the answer would not change. So the exact answer to the problem is 0.95493 feet, but if you said "about 1 foot" you were right.

## Sunday, January 1, 2017

### Voyageurs

I've been reading

*The Revenant*by Michael Punke and came across the following few passages. The main character, Hugh Glass, is embarking on a canoe trip up the Missouri River with a group of French Canadian fur traders known as voyageurs....For the rest of their voyage, Glass manned not a paddle but an enormous sponge, constantly bailing water as it pooled on the bottom of the canoe.

It was a full-time job, since theIf you've ever maintained a large code base, you probably already see where I'm going with this. The constant patching and plugging of leaks, the fragility of the craft, one man constantly bailing out water while several others row the boat guided by a steersman. These elements all remind me of several large software projects I've been on. The passage continues.bĂ˘tardleaked steadily. The canoe reminded Glass of a floating quilt. Its patchwork skin of birch bark was sewn together withwattope, the fine root of a pine tree. The seams were sealed with pine tar, reapplied constantly as leaks appeared. As birch had become more difficult to find, the voyageurs were forced to use other materials in their patching and plugging. Rawhide had been employed in several spots, stitched on and then slathered in gum. Glass was amazed at the fragility of the craft. A stiff kick would easily puncture the skin, and one of La Vierge's main tasks as steersman was the avoidance of lethal, floating debris. At least they benefited from the relatively docile flow of the fall season. The spring floods could send entire trees crashing downstream.

There was an upside to theThis reminds me not only of the relationship programmers have with our code, but also of the relationship we have with our tools. How much time do we spend complaining about an IDE or a framework? How much time configuring them? But after we've gotten comfortable using them, most of us will strongly resist switching to a new one. Finally...bĂ˘tard'sshortcomings. If the vessel was frail, it was also light, an important consideration as they labored against the current. Glass came quickly to understand the odd affection of voyageurs for their craft. It was a marriage of sorts, a partnership between the men who propelled the boat and the boat that propelled the men. Each relied upon the other. The voyageurs spent half their time complaining bitterly about the manifold ails of the craft, and half their time nursing them tenderly.

They took great pride in the appearance of theThis final bit surprises me the most, but in a way I suppose it shouldn't. I don't know much about boating, but I do know that you should fix the leaks in your boat before you bother to decorate it. But that isn't how we always approach software development, is it? I've seen people spend plenty of time refactoring and cleaning code that didn't really need to change, or adding test cases just to get a higher percentage in test coverage. At times I've been guilty of this myself. I guess it's worth it to ask yourself, before you make a change to your code, am I fixing a leak, or am I just painting a stag's ass on this canoe?bĂ˘tard,dressing it in jaunty plumes and bright paint. On the high prow they had painted a stag's head, its antlers tilted challengingly toward the flowing water. (On the stern, La Vierge had painted the animal's ass.)

Labels:
engineering,
history,
software

Subscribe to:
Posts (Atom)