You're about to leave for an international vacation where you'll be visiting ten different foreign countries. To make sure you don't catch any local diseases, your doctor has given you ten pills and instructed you to take one as you arrive in each country. The pills all contain different medicines, so very it's important that you take the pills in the right order.

Unfortunately, the ten pills are all identical. Fortunately, you also have ten pill bottles you can put them in. Unfortunately, the pill bottles are also all identical, and there's no way for you to carry them without them getting jumbled up. Fortunately, your doctor also has a machine that can print out little stickers with whatever positive whole numbers you want on them which you can use to label your pills and bottles. Unfortunately, those stickers each cost \$100 times the number printed on them (e.g., a sticker labelled "9" would cost \$900), and official, intact stickers are the only thing that international customs will permit you to use to label your medications with.

Given all of that, how can you use those things to reliably distinguish which pill you need to take at each step in your itinerary without spending any more on stickers than you have to?

(I have an answer to this, but I don't know whether or not it's optimal. I'm curious whether or not anyone can find a better solution than mine.)

  • 1
    $\begingroup$ Are two bottles labeled with the same number assumed to be indistinguishable? Realistically, different placements and orientations or even labeling the inside are imaginable. $\endgroup$
    – noedne
    Jul 25, 2022 at 4:11
  • 2
    $\begingroup$ Is it per number or per digit? A "9" costs $900, but what would a "11" cost? $1100 or $200? $\endgroup$
    – vsz
    Jul 25, 2022 at 10:34
  • 2
    $\begingroup$ @DmitryKamenetsky A whole sticker right on the pill. The special non-toxic glue is part of why those stickers are so expensive. $\endgroup$ Jul 25, 2022 at 11:41
  • 4
    $\begingroup$ what would 1 01 001 0001 ... cost? $\endgroup$
    – frag
    Jul 25, 2022 at 15:07
  • 2
    $\begingroup$ Lateral answer: Fire the doctor and go find one who prescribes medicine rationally. :) $\endgroup$
    – Bobson
    Jul 25, 2022 at 16:45

11 Answers 11


Total cost:



1 unlabelled, unbottled pill

1 labelled "1", unbottled pill

1 unlabelled pill in an unlabelled bottle

1 labelled "1" pill in an unlabelled bottle

1 unlabelled pill in a bottle labelled "1"

1 unlabelled and 1 labelled "1" pill in an unlabelled bottle

1 unlabelled, 1 labelled "1" and 1 labelled "2" pills in an unlabelled bottle

When consumed in the order listed there will never be ambiguity.

  • 2
    $\begingroup$ I think this is provably optimal since the only possible groups that cost less than $100 per pill are your 1st, 3rd, and 6th ones. $\endgroup$
    – xnor
    Jul 25, 2022 at 4:31
  • 3
    $\begingroup$ I thought all pills must be in a bottle? So is 1 and 2 allowed? $\endgroup$ Jul 25, 2022 at 6:12

This is probably not the intended answer, but how about this:

Place all bottles in a straight line and connect them all with one long "1" sticker, costing you \$100. Write the "1" on the part of the sticker on the left-most bottle, so you know that it is the start. Now place the first pill in the left-most bottle, the second pill in the second bottle from left and so on. In country $k$ you simply take the $k$-th pill from the left. The total cost is $100.

slight variation:

I guess a line of bottles is not very compact for travelling and you may not have a long sticker. So you could place them in a circle and put a rubber band around them to hold them together. Place the "1" sticker on the first bottle. Now you simply eat pills in a clockwise order, starting from the one with the sticker. This also costs $100, but requires a rubber band, which may not be allowed.

Another variation, which is my favourite:

Stack the bottles vertically and eat pills from top to bottom. If we are allowed to do this then this is optimal as it doesn't cost anything.


First off, one bottle can be

left unlabelled, because it's uniquely identifiable from not having a label as long as all other bottles do have them.

For the rest, we can

greedily pick the cheapest label for each of the remaining 9 bottles that doesn't repeat any previous label.

All in all:

1: No label. Cost \$0.
2: One label "1". Cost \$100.
3: Two labels "11". Cost \$200.
4: One label "2". Cost \$200.
5: Three labels, "111". Cost \$300.
6: Two labels, "12". Cost \$300.
7: Two labels, "21". Cost \$300.
8: One label "3". Cost \$300.
9: Two labels, "13". Cost \$400.
10: Two labels, "22". Cost \$400.

Summing everything together we're spending \$2,500 on stickers.

  • $\begingroup$ Per later comments, the "11" bottle would actually cost \$1100, not \$200. $\endgroup$
    – Bobson
    Jul 25, 2022 at 16:44
  • $\begingroup$ Understand: 2 labels, "1", "1'. $\endgroup$
    – Florian F
    Jul 26, 2022 at 9:19

I think it's fair to say this is optimal:

Buy one $100 sticker. Cut it into 45 pieces. Label the first bottle with 0 pieces, the second with one piece, the third with two pieces, and all the way up until the tenth bottle, which will have nine pieces on it.

  • 1
    $\begingroup$ Nice loophole, but not what I intended. I've updated the puzzle description to clarify that the stickers need to be intact. $\endgroup$ Jul 25, 2022 at 3:25

Here is my answer with all pills are inside the bottles.


as ( Pills - Bottles)

L - U

U - L

U - U

L U - U

L U - L

2L L U - U

  • $\begingroup$ yep just got it. $\endgroup$ Jul 25, 2022 at 13:44

Total cost:$200

How? Cut sticker number 2 into 9 equal parts and distribute to 9 bottles except the first one

  • $\begingroup$ Clever. I've updated the puzzle description to clarify that the stickers must be intact. $\endgroup$ Jul 25, 2022 at 3:24
  • 2
    $\begingroup$ why not sticker "1"? It would be cheaper. $\endgroup$ Jul 25, 2022 at 6:08
  • 1
    $\begingroup$ Probably covers to little space on the sticker to make 9 distinguishable pieces. $\endgroup$
    – haxor789
    Jul 25, 2022 at 12:15

total cost: 700

  • 1 unlabelled unbottled pill
  • 1 unlabelled bottled pill
  • 2 pills in an unlabeled bottle with a '1' label on one pill
  • 2 pills in a bottle with a '1' label on the cap and a '1' label on one pill
  • 2 pills in a bottle with a '1' label on the base and a '1' label on one pill
  • 2 pills in a bottle with a '1' label on the body and a '1' label on one pill
  • $\begingroup$ check the comments on the question, labels in different places on the bottle are indistinguishable (aka the only data you have about the label is whether or not it's there, and what number is on it) $\endgroup$
    – Esther
    Jul 25, 2022 at 15:42

First of all it would be necessary for OP to confirm whether or not:

0 is a positive integer. That's is as far as I can see not a trivial statement and worthy of adding it to the question if it is not considered one.

In that case the answer would be simply $0

In case it is not a positive integer:

I'd argue that the answer is $500:

Here I'd take a modified approach to what loopy wait proposed:

1 unlabelled unbottled pill ($0)

1 unlabelled bottled pill ($0)

3 pills in an unlabeled bottle. One with a '1' label on one pill, one stuck to the wall with a "1" label, and one without label ($200)

3 pills in an unlabeled bottle, one pill labeled with a "1" and one stuck to a different place on the wall with a "1". (Maybe stuck to the outside of the wall) ($200)

last two pills in an unlabeled bottle with 1 pill labeled ($100)

That would require only 5 labels with "1" and therefore $500

  • $\begingroup$ I think it is clear that $0$ is not a positive integer. One speaks of nonnegative integers if $0$ is to be included. $\endgroup$ Jul 26, 2022 at 5:06
  • $\begingroup$ The page you linked in a comment on your now-deleted answer states "it is the only integer that is neither positive nor negative." $\endgroup$
    – noedne
    Jul 26, 2022 at 15:36

Total cost of


You can just use one label and attach all 10 pills on the inner side of the bottle, using one label with "1" on it, in the order you need to eat them. For example, you can arrange them with the first pill at the bottom and the last pill at the top and eat the pills ascending upwards. So you eat the pill attached at the bottom first, then the one above it, then the one above that until you have taken all the pills.

In the case the label isn't long enough to have all 10 pills below it you can do it in $400

Going with the trend of the other answers with an unbottled pill
You would have:
1 unlabeled bottle with one pill
1 unlabeled unbottled pill
2 pills in one bottle. One unlabeled pill and another pill is attached to the bottom of the bottle using a "1" label.
2 pills in another bottle. One unlabeled pill and another pill attached inner lower side of the bottle using a "1" label
2 pills in another bottle. One unlabeled pill and another pill stuck to the middle side of the bottle using a "1" label
2 pills in another bottle. One unlabeled pill and another pill stuck to the upper side of the bottle using a "1" label
With this, you only use 4 labels printed with 1 so a total cost of $400 and you can differentiate each bottle with the location of the label. The pills without a bottle could be first, then the unlabeled bottle with one pill, then the unlabeled pill in the bottle with the label on the bottom, then the pill stuck below that label, etc..

and in the case you can't have a pill outside a bottle, you could do it in $500 using 5 labels with that unlabeled, unbottled pill inside the unlabeled bottle with one pill attached to the walls in a different location.


I may have misread the question, but total cost:



Print off 55 stickers labelled with 0. Place one on bottle #1, two on #2, etc.(or 45 stickers if you label 9 bottles and leave one blank).

  • $\begingroup$ Stickers must have a positive number, so you cannot have 0 $\endgroup$ Jul 25, 2022 at 12:13

Not sure if

"positive, whole numbers" exclude 0,

but if not, then

I would have them print labels of "0", "00", "000", etc. all for free,

Making the grand total $0.

  • 1
    $\begingroup$ 0 is not a positive number and this answer has been already suggested. $\endgroup$ Jul 25, 2022 at 12:15
  • $\begingroup$ I knew I'd missed something obvious $\endgroup$
    – Mohirl
    Jul 25, 2022 at 12:48
  • $\begingroup$ @DmitryKamenetsky Forgetting the fact, that the other answer was put in the exact same minute, mine was actually 29sec earlier. Thanks for the "feedback" though. $\endgroup$
    – Minix
    Jul 29, 2022 at 12:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.