Monthly Archives: September 2009

The Coffee Bean Puzzle — Solution

If you haven’t looked at the puzzle yet, check out the Coffee Bean Puzzle first.

Solution below…

Getting closer…

Okay. So the operations allowed were described like this:

  1. Pull out two beans at random. If the two beans are the same color, replace them with a white bean.
  2. Pull out two beans at random. If the two beans are different, replace them with a black bean.

You can rephrase the “take two beans out and then do something”  to be a single action like this:

  1. Operation 1 above where both beans were white: remove one white bean.
  2. Operation 1 above where both beans were black: remove two black beans and put in a white bean.
  3. Operation 2 above: remove one white bean.

Note that 1 and 3 are the same operation. So there are really only two operations. You pull out two beans at random to see what to do, and then:

  1. If the beans were both white or were different colors, then take out one white bean and put the other back.
  2. If the beans are both black, remove them and put in a white bean.

Now it’s clearer: you can put in a white bean, and you can remove a white bean, but you can only remove black beans in pairs. Given that, the last bean is determined by the even-ness or odd-ness of the black beans. If they are odd in number, the last bean will be black. Otherwise, because the last black beans will be a pair, which under rule 2 produces a white bean, the last bean will be white.

There is another method of solving this (the one I actually used) that is either overcomplicating the situation, or perhaps offers better insight. I’m trying to devise a more complex variant of this puzzle to see which is the case.

Advertisements

The coffee bean puzzle

There is a puzzle listed at http://www.cs.cmu.edu/~mblum/research/pdf/grad.html that goes as follows:

Given a can of black and white coffee beans, do the following: Pull out two beans: if both are the same color, replace them with a white bean. If the two are different, replace them with a black bean. What color is the last bean?

I thought about it for a while and figured out the answer, but I was unsatisfied with the way the puzzle is phrased, because there isn’t one set answer: from the information given the last bean cannot be said to be either black or white. Instead, the answer is a simple method of determining the color of the last bean, given additional information. This discrepancy led me to waste some time trying to find a determinative answer first, and then to question whether I really had the correct answer once I had found it. But just giving the requisite information in addition to the above description gives too much of a hint, and collapses the puzzle to a much simpler one. So I would phrase the puzzle like this:

Given a can of black and white coffee beans, you are allowed to do the following operation repeatedly. Pull out two beans, then:

  1. If the two beans are the same color, replace them with a white bean.
  2. If the two beans are different, replace them with a black bean.

What simple method can you use to know what the color of the last bean will be?

Now it’s clear that there is no set answer, but hopefully I haven’t given away too much. The answer will be in a separate post.

“The Complete Idiot’s Guide…” — a little too truthful

I happened across a deal on The Complete Idiot’s Guide to Statistics by Robert A. Donnelly, Jr., Ph.D., at the bookstore. I wanted to brush up a little, so I grabbed it. Unfortunately I’m not even through the first chapter and I’m disappointed. Part of chapter one describes the issues with data presentation. It shows two graphs presenting the fact that the author took some golf lessons and lowered his average score from 98 to 96 from May to July. Here’s his example of a misleading graphic:

Misleading -- bad graphic, no biscuit!

Misleading -- bad graphic, no biscuit!

He’s correct, that graphic is misleading. Chopping off the bottom of a graph to accentuate the differences should always be questioned. But the alternative he proposes is worse:

Worse graphic -- no biscuit for the rest of the week!

Worse graphic -- no biscuit for the rest of the week!

First off, at a minimum it takes 18 shots to complete a round of golf, so starting at 0 is just silly. But realistically the goal is par. If par on the courses he plays is 72, the graphic might look like this:

Getting better -- maybe worth a biscuit...

Getting better -- maybe worth a biscuit...

But that still ignores the fact that par isn’t the same from course to course. Maybe in May he was playing on a par 76, and in July on a par 72, in which case he’s actually gotten worse after the lessons. That’s why people comparing their golf skills talk about how many shots over par they average. So the right way to graph this looks like this:

Have a biscuit!

Have a biscuit!

A golfer who is currently averaging 26 over par might only be looking to improve to 15, so it might be reasonable to baseline the graph there, or at 10. You might expect later gains to come harder, so a logarithmic presentation could make sense. At this point I’m just throwing out alternatives — the main point is that baselining the graph at 0 shows a complete lack of understanding of data presentation, or golf, or both.

Disneyland half marathon results

First, I forgot to post my results for the Jet to Jetty 10K on August 22nd — 57:08. Not as fast as I hoped, but a significant improvement on the last 10K I ran in October 2008. That was 1:08:42.7, so peeling off well over eleven minutes feels pretty good.

So for the half marathon, I finished in 2:13:08. Not quite my goal of ten minute miles, and nowhere near my stretch goal of two hours, but not bad overall. There was a ton of congestion for the first several miles, and I had to take an unexpected break for a few minutes in the middle to (ahem) lighten the load a bit. One thing I notice in the results is that several people who finished with near my chip time (actual time on the course) finished with nearly the same clock time (time since the start of the race). That means they started at nearly the beginning of the race, which I think only happens if you sign up for a highly competitive pace. Optimists, or dissemblers?

All in all it was a good experience, but if I run another half marathon, I’m going to be looking for one that’s not so popular, or just measuring out the distance myself. I don’t need bands and screaming cheerleaders to keep me moving.

I do need a change of clothes, I think. My shirt and shorts were saturated long before the finish, and I wonder what effect that has on performance. Keeping cool is critical, and sweating does no good if you’re already soaked.

Patents and world medicine — trying not to look like a heartless jerk

In Please give us all your money – Bad Science, Ben Goldacre discusses the situation with patents and the world drug market. The first example noted is Tenofovir, which he says costs $5,700 per patient per year in developed countries and $800 per patient per year in the rest of the world. The reason for the price difference is Indian pharmaceutical companies, which manufacture generic versions of many drugs, apparently within the bounds of Indian law, but to the dismay of the patent-holders.The math on this is puzzling. Goldacre says that “75% of the 4m people in the world taking medication for Aids are using generic copies.” I don’t know what percentage of those four million are taking Tenofovir or its generic equivalents, but to make the math simpler, let’s say it’s all of them. That means that one million in the developed world are taking Tenofovir at $5700 per year, grossing $5.7 billion per year for Gilead, the patent-holder, and three million in the rest of the world are taking the generic equivalent at $800 per year, grossing $2.4 billion for various Indian companies.If Gilead lowered their price to $800 per year across the board from the beginning, they could have four million people taking their original version of Tenofovir, grossing them $3.2 billion per year. I’d take $3.2 billion with no competitive headaches and a ton of worldwide goodwill over $5.7 billion any day.Of course, perhaps if Gilead started at $800, competitors would rush in at $600, or $400. Obviously there’s a cost to manufacturing the drug and I have no idea what it is. Let’s say it’s $500 for a year’s supply. Then the math gets trickier. As things are now, Gilead is grossing $5.7 billion against a manufacturing cost of just $500 million — $5.2 billion of sweet sweet profit. If they take the $800 route as I’m suggesting, they gross $3.2 billion with manufacturing costs of $2 billion, so they only make $1.2 billion profit. I’d still say that’s a bargain for not looking like heartless jerks.Of course, unfortunately, it’s almost impossible not to look like a heartless jerk when you’re trying to make a profit saving lives. It’s a tough situation for Gilead, and probably there are no easy answers, including mine.

Patents and world medicine — trying not to look like a heartless jerk

In Please give us all your money – Bad Science, Ben Goldacre discusses the situation with patents and the world drug market. The first example noted is Tenofovir, which he says costs $5,700 per patient per year in developed countries and $800 per patient per year in the rest of the world. The reason for the price difference is Indian pharmaceutical companies, which manufacture generic versions of many drugs, apparently within the bounds of Indian law, but to the dismay of the patent-holders.

The math on this is puzzling. Goldacre says that “75% of the 4m people in the world taking medication for Aids are using generic copies.” I don’t know what percentage of those four million are taking Tenofovir or its generic equivalents, but to make the math simpler, let’s say it’s all of them. That means that one million in the developed world are taking Tenofovir at $5700 per year, grossing $5.7 billion per year for Gilead, the patent-holder, and three million in the rest of the world are taking the generic equivalent at $800 per year, grossing $2.4 billion for various Indian companies.

If Gilead lowered their price to $800 per year across the board from the beginning, they could have four million people taking their original version of Tenofovir, grossing them $3.2 billion per year. I’d take $3.2 billion with no competitive headaches and a ton of worldwide goodwill over $5.7 billion any day.

Of course, perhaps if Gilead started at $800, competitors would rush in at $600, or $400. Obviously there’s a cost to manufacturing the drug and I have no idea what it is. Let’s say it’s $500 for a year’s supply. Then the math gets trickier. As things are now, Gilead is grossing $5.7 billion against a manufacturing cost of just $500 million — $5.2 billion of sweet sweet profit. If they take the $800 route as I’m suggesting, they gross $3.2 billion with manufacturing costs of $2 billion, so they only make $1.2 billion profit. I’d still say that’s a bargain for not looking like heartless jerks.

Of course, unfortunately, it’s almost impossible not to look like a heartless jerk when you’re trying to make a profit saving lives. It’s a tough situation for Gilead, and probably there are no easy answers, including mine.