Prealgebra · Lesson 10.3

Casework

Solve this lesson, free →All lessons

One multiply only works when the choices stay the same all the way across. When they change partway through, split what you are counting into separate cases, count each case on its own, and add the counts.

Problem
A food truck sells tacos (with \(1\) of \(5\) fillings) and burritos (with \(1\) of \(4\) fillings and \(1\) of \(2\) salsas). How many different single items can you order?
Show a hint
  • You cannot count this with one clean multiply, because a taco has just one choice to make and a burrito has two. So split it. What are the two separate piles of items you are choosing from?
  • Make two cases, one for tacos and one for burritos. A taco is fully decided by its single filling. A burrito is decided by its filling and its salsa together. Count each case on its own.
  • Tacos give you \(5\) ways. For burritos you pick one of \(4\) fillings and one of \(2\) salsas, which is \(4 \times 2 = 8\) ways. Now you just have the two pile counts \(5\) and \(8\) sitting in front of you.
Show the full solution
There are \(5\) tacos, one for each filling. A burrito needs a filling and a salsa, so there are \(4 \times 2 = 8\) burritos. Nothing is both, so add the two piles, $$5 + 8 = 13.$$ You can order \(\boxed{13}\) different items. One multiply cannot handle this in one shot, since a taco makes one choice and a burrito makes two. Multiply inside a case, add across cases.
Problem
Zedland has a 6-letter alphabet. Words can be 1, 2, or 3 letters long, with repeats allowed. How many possible words are there?
Show a hint
  • The words come in different lengths, and a one-letter word and a three-letter word are built in very different ways. Try splitting the count by how long the word is, so you handle each length on its own.
  • Set up three piles. Count the one-letter words, then the two-letter words, then the three-letter words. Inside each pile every slot has \(6\) choices, so a one-letter word has \(6\) options, a two-letter word has \(6 \times 6\), and a three-letter word has \(6 \times 6 \times 6\).
  • Work out each pile and you get \(6\) one-letter words, \(6^2 = 36\) two-letter words, and \(6^3 = 216\) three-letter words. All that is left is to add the three pile counts together.
Show the full solution
Count by length. One-letter words give \(6\), two-letter words give \(6^2 = 36\), and three-letter words give \(6^3 = 216\). A word has exactly one length, so the piles do not overlap and you add, $$6 + 36 + 216 = 258.$$ There are \(\boxed{258}\) possible words. Inside a case every slot has \(6\) choices, so you multiply. Across the cases you add.
ABCDEFH
Here is the road map we will use for the next two problems. You start at town \(A\) on the left and travel through some of the towns \(B\), \(C\), \(D\), \(E\), \(F\), and \(H\), always moving left to right and never doubling back. There are two roads running from \(A\) to \(B\), and every other link is a single road. Notice the two handy shortcuts as well, a direct road from \(A\) to \(D\) and a direct road from \(D\) to \(H\). Follow the arrows and see where the roads can take you.
Problem
Using the map above, there are \(4\) routes from A to D, and from D to H there are \(3\) routes (via E, via F, or direct). How many routes go all the way from A to H?
Show a hint
  • The whole trip squeezes through one town. Every route from \(A\) to \(H\) has to pass through \(D\), so split the route at \(D\) into the first stretch \(A\) to \(D\) and the second stretch \(D\) to \(H\), and handle each pile on its own.
  • You are told the first stretch \(A\) to \(D\) has \(4\) routes. Now count the second stretch \(D\) to \(H\) by listing its cases. There is \(D\) to \(E\) to \(H\), there is \(D\) to \(F\) to \(H\), and there is the direct road \(D\) to \(H\).
  • So the second stretch has \(3\) routes. Picking a way from \(A\) to \(D\) and then a way from \(D\) to \(H\) are two independent choices, so this is a multiply, not an add. You just need \(4\times 3\).
Show the full solution
From \(D\) to \(H\) there are \(3\) routes, one through \(E\), one through \(F\), and the direct road. Each of the \(4\) routes from \(A\) to \(D\) can be followed by any of those, so $$4 \times 3 = 12.$$ There are \(\boxed{12}\) routes from \(A\) to \(H\). Every route passes through \(D\), which is why the trip splits there. The two halves are independent, so this step is a multiply, not an add.
everything we are counting Case 1 6 Case 2 8 Case 3 5 add the cases 6 + 8 + 5 = 19
The big top box holds everything we want to count. We split it into three separate cases that do not overlap, here \(6\) things in Case 1, \(8\) in Case 2, and \(5\) in Case 3. Count each case on its own, then add them up and you get \(6 + 8 + 5 = 19\).
Alphabet { A , B } length 1 length 2 A B Aa Ab Ba Bb 2 words 4 words 2 + 4 = 6 words in all
Here is a tiny alphabet with just two letters, \(A\) and \(B\). To count every short word we sort them by how many letters they have. There are \(2\) words of length one, namely \(A\) and \(B\). There are \(4\) words of length two, namely \(AA\), \(AB\), \(BA\), and \(BB\). We handled each length on its own, then we add the piles together and you get \(2 + 4 = 6\) words in all. That is the heart of casework, split the job into clear cases, count each one, then add.
Problem
Every whole number from \(1\) to \(150\) is written out. How many digits are written in total?
Show a hint
  • One clean multiply will not work here, because the numbers are not all the same length. The number \(7\) uses one digit, \(43\) uses two, and \(128\) uses three. So split your count into piles by how many digits each number has.
  • Make three piles. The one-digit numbers run from \(1\) to \(9\), the two-digit numbers run from \(10\) to \(99\), and the three-digit numbers run from \(100\) to \(150\). Inside each pile, count how many numbers there are and multiply by the digits each one uses.
  • Pile one gives \(9\times1=9\) digits, pile two gives \(90\times2=180\) digits, and pile three gives \(51\times3=153\) digits. Now you just need to bring the three pile counts together.
Show the full solution
Split by how many digits a number has. The numbers \(1\) to \(9\) are \(9\) numbers with \(1\) digit each, so \(9\times1=9\). The numbers \(10\) to \(99\) are \(90\) numbers with \(2\) digits each, so \(90\times2=180\). The numbers \(100\) to \(150\) are \(51\) numbers with \(3\) digits each, so \(51\times3=153\). Adding the piles, $$9+180+153=342,$$ so you write \(\boxed{342}\) digits. The piles never overlap and together cover every number, so nothing is counted twice and nothing slips through.
Problem
How many two-digit numbers have a tens digit greater than the units digit?
Show a hint
  • You cannot just multiply choices for the two digits, because once you pick the tens digit, the number of allowed units digits depends on what you picked. Try splitting the count by the tens digit, and handle each tens digit as its own pile.
  • Pick a tens digit and call it \(t\). It can be anything from \(1\) to \(9\). For that fixed \(t\), the units digit just has to be smaller, so it can be \(0, 1, \ldots, t-1\), which is \(t\) choices.
  • So the tens digit \(t=1\) gives \(1\) number, \(t=2\) gives \(2\) numbers, on up to \(t=9\) giving \(9\) numbers. Now you just need the total of \(1+2+\cdots+9\).
Show the full solution
Case on the tens digit \(t\). The units digit only has to be smaller, so it can be \(0, 1, \ldots, t-1\), which is \(t\) choices. Running \(t\) from \(1\) to \(9\) and adding gives $$1+2+3+4+5+6+7+8+9 = 45,$$ so there are \(\boxed{45}\) such numbers. You cannot just multiply \(9\times10\) here, because how many units digits are allowed depends on which tens digit you picked.
Problem
Hat 1 holds balls numbered \(1\) to \(15\) and Hat 2 holds balls \(16\) to \(25\). You pick one hat, then draw \(2\) balls from it one after another without replacement, where order matters. How many different ordered draws are possible?
Show a hint
  • The two hats hold different amounts of balls, so one clean multiply will not work for the whole thing at once. Try splitting the count by which hat you reached into.
  • Set up two piles. In the hat one pile you draw from \(15\) balls, and in the hat two pile you draw from \(10\) balls. Count the ordered draws in each pile on its own.
  • Hat one gives \(15\times14=210\) ordered draws and hat two gives \(10\times9=90\) ordered draws. Now you just need to put the two pile counts together.
Show the full solution
Split by hat. Hat 1 holds \(15\) balls, so the two draws give \(15\times14=210\). Hat 2 holds \(10\) balls, so \(10\times9=90\). A draw comes from exactly one hat, so add, $$210+90=300.$$ That is \(\boxed{300}\) ordered draws. The second factor drops by one because the first ball stays out. The hats hold different amounts, which is why one multiply cannot cover both at once.
Problem
Using pennies, nickels, and dimes (any amounts, including zero), how many ways can you make \(20\) cents?
Show a hint
  • One clean multiply will not work here, because the coins are not interchangeable. Try splitting the problem into piles based on the coin that limits you the most. Since dimes are the biggest, ask how many dimes you use and make a separate case for each choice.
  • Figure out which numbers of dimes are even possible. You can use \(0\) dimes, \(1\) dime, or \(2\) dimes, since \(3\) dimes would already be \(30\) cents, which is too much. So you have exactly three cases to count, one for each of those dime counts.
  • In each case, count how many nickels can fit in the leftover amount, and let pennies quietly fill whatever is still missing. With \(0\) dimes you have \(20\) cents to fill, so nickels can be \(0,1,2,3,\) or \(4\). With \(1\) dime you have \(10\) cents left, so nickels can be \(0,1,\) or \(2\). With \(2\) dimes you have \(0\) cents left, so nickels must be \(0\). Now you just need to add the three pile counts together.
Show the full solution
Case on the number of dimes. With \(0\) dimes there is \(20\) cents to fill, so the nickels can be \(0, 1, 2, 3,\) or \(4\) and pennies fill the rest, which is \(5\) ways. With \(1\) dime there is \(10\) cents left, so nickels can be \(0, 1,\) or \(2\), which is \(3\) ways. With \(2\) dimes nothing is left, which is \(1\) way. Three dimes is already \(30\) cents, too much. Adding, $$5 + 3 + 1 = 9,$$ so there are \(\boxed{9}\) ways. Split on the coin that boxes you in the most, here the dime. Once the dimes and nickels are set, the pennies are forced, so there is nothing left to choose.
Counting pairs with a² + b < 13 case: a what it forces count a = 1 b < 12 11 a = 2 b < 9 8 a = 3 b < 4 3 a = 4 forces a² = 16, too big, so we stop Total = 11 + 8 + 3 22 Each case is counted once, then we add.
Here we count positive pairs \(a\) and \(b\) with \(a^2 + b < 13\), and the table sorts them by the value of \(a\). When \(a = 1\) we need \(1 + b < 13\), so \(b < 12\) and that gives \(11\) choices. When \(a = 2\) we need \(4 + b < 13\), so \(b < 9\) which gives \(8\) choices. When \(a = 3\) we need \(9 + b < 13\), so \(b < 4\) which gives \(3\) choices. Trying \(a = 4\) makes \(a^2 = 16\), already too big, so we stop. Adding the three case counts down the last column gives $$11 + 8 + 3 = 22.$$ A table keeps cases organized so you add them up without missing one, and you land on \(\boxed{22}\).
Problem
How many ordered pairs of positive integers \((a, b)\) satisfy \(a^2 + b < 24\)?
Show a hint
  • Try the slot method and you will notice the choices for \(b\) shrink as \(a\) grows, so one clean multiply will not work. Split into cases by the value of \(a\) instead, and count each value on its own.
  • Pin down \(a\) first. If \(a = 1\) then you need \(1 + b < 24\), so \(b < 23\). If \(a = 2\) then \(4 + b < 24\), so \(b < 20\). Keep going for \(a = 3\) and \(a = 4\), and check where \(a^2\) alone already pushes past \(24\).
  • Count the allowed \(b\) values in each case, remembering \(b\) starts at \(1\). You should get \(22\) for \(a = 1\), then \(19\), then \(14\), then \(7\), and nothing for \(a = 5\). Now add those pile counts.
Show the full solution
Case on \(a\). With \(a=1\) we need \(1+b<24\), so \(b<23\) and \(b\) runs \(1\) to \(22\), which is \(22\) pairs. With \(a=2\), \(b<20\) gives \(19\) pairs. With \(a=3\), \(b<15\) gives \(14\). With \(a=4\), \(b<8\) gives \(7\). At \(a=5\) we already have \(a^2=25\), too big on its own, so we stop. Adding, $$22 + 19 + 14 + 7 = 62,$$ so there are \(\boxed{62}\) pairs. The room left for \(b\) shrinks as \(a\) grows, so no single multiply works. Watch the endpoint too, since \(b<23\) means \(22\) values, not \(23\).
Problem
How many two-digit numbers have digits that add up to a perfect square?
Show a hint
  • The slot method from 10.2 will not work here in one clean multiply, because the digit sum can land on a few different perfect squares and each one behaves differently. So split into cases by the digit sum. First figure out which perfect squares a digit sum can even reach.
  • The two digits of a two-digit number add up to somewhere between \(1\) and \(18\). The perfect squares living in that range are \(1\), \(4\), \(9\), and \(16\). Make one case for each of those four sums, then count the two-digit numbers in each case on its own.
  • Sum \(=1\) gives just \(10\), so \(1\) number. Sum \(=4\) gives \(4\) numbers, and sum \(=9\) gives \(9\) numbers. Sum \(=16\) gives \(3\) numbers. Now add the four pile counts the way you added in 10.1.
Show the full solution
Two digits add to somewhere between \(1\) and \(18\), so the perfect squares in reach are \(1\), \(4\), \(9\), and \(16\). Sum \(1\) gives only \(10\), so \(1\) number. Sum \(4\) gives \(13\), \(22\), \(31\), \(40\), so \(4\). Sum \(9\) gives \(18\), \(27\), \(36\), \(45\), \(54\), \(63\), \(72\), \(81\), \(90\), so \(9\). Sum \(16\) gives \(79\), \(88\), \(97\), so \(3\). Adding, $$1 + 4 + 9 + 3 = 17,$$ so there are \(\boxed{17}\) numbers. Pinning down which sums are even reachable is most of the work. Miss one square and the count comes up short.
Problem
How many three-digit numbers have exactly one digit equal to \(0\)?
Show a hint
  • The leading digit of a three-digit number can never be \(0\), since a number like \(047\) is really just \(47\). So the lone \(0\) has nowhere to hide in the hundreds spot. That tells you the two places where the single \(0\) could actually sit, and those two spots are a perfect thing to split into cases on.
  • Make two cases. In the first case the \(0\) sits in the tens place and the units digit is not \(0\). In the second case the \(0\) sits in the units place and the tens digit is not \(0\). Inside each case, figure out how many choices the hundreds digit has and how many choices the remaining free digit has, then multiply those two counts.
  • Case one gives \(9 \times 9 = 81\), and case two gives \(9 \times 9 = 81\). The two cases never overlap and together they cover every way to have exactly one \(0\). All that is left is to combine the two pile counts.
Show the full solution
The hundreds digit is never \(0\), since \(061\) is really just \(61\). So the lone \(0\) sits in the tens place or the units place. With the \(0\) in the tens place, the hundreds digit has \(9\) choices and the units digit has \(9\), giving \(9\times9=81\). The \(0\) in the units place works the same way, another \(81\). Adding, $$81 + 81 = 162,$$ so there are \(\boxed{162}\) numbers. The other free digit has to be nonzero, or you would have two zeros instead of exactly one.
Problem
How many three-digit numbers have a hundreds digit that is at least \(3\) times the tens digit?
Show a hint
  • The rule only ties together the hundreds digit and the tens digit, and the units digit is free with all \(10\) choices no matter what. So the tidiest thing to split on is the tens digit \(t\), because once you fix \(t\) the demand "hundreds is at least \(3t\)" becomes one simple count.
  • Walk the tens digit through its values and ask how many hundreds digits from \(1\) to \(9\) clear the bar \(3t\). When \(t=0\) you need hundreds at least \(0\), so all of \(1\) to \(9\) work. When \(t=1\) you need hundreds at least \(3\). When \(t=2\) you need at least \(6\). When \(t=3\) you need at least \(9\). When \(t\) is \(4\) or more, even \(9\) is too small, so those cases give nothing.
  • Count the hundreds choices in each living case, then remember every one of those still gets \(10\) free units digits. You should have hundreds counts of \(9\), \(7\), \(4\), and \(1\) for \(t=0,1,2,3\). Add those, then multiply by \(10\).
Show the full solution
Case on the tens digit \(t\). The units digit never appears in the rule, so it always brings \(10\) choices. For \(t=0\) the hundreds digit needs to be at least \(0\), so all \(9\) work. For \(t=1\) it must be at least \(3\), so \(7\) work. For \(t=2\), at least \(6\), so \(4\). For \(t=3\), at least \(9\), so \(1\). For \(t=4\) or more you would need a digit of \(12\) or bigger, so those piles are empty. That gives $$9 + 7 + 4 + 1 = 21$$ hundreds-tens pairs, each carrying \(10\) units digits, so $$21 \times 10 = 210.$$ The count is \(\boxed{210}\). A digit no rule touches just multiplies in at the end. Pull it out early and the casework gets much shorter.
Problem
How many whole numbers from \(1\) to \(999\) have at least one digit equal to \(2\)?
Show a hint
  • Counting the numbers that DO have a \(2\) splits into messy overlapping cases, the \(2\) could be in the ones, the tens, or the hundreds place, and some numbers have it in more than one spot. The slick split is just has a \(2\) versus does not have a \(2\). Count the friendlier side, the ones with no \(2\) at all, and subtract from the total.
  • Picture every number from \(1\) to \(999\) as three digit slots, like \(007\) for \(7\) or \(052\) for \(52\). For a slot to avoid the digit \(2\), it can be any of \(\{0,1,3,4,5,6,7,8,9\}\), which is \(9\) choices. Multiply the slots the 10.2 way to count all three-slot strings with no \(2\).
  • Three slots with \(9\) choices each gives \(9\times9\times9=729\) strings from \(000\) to \(999\) that avoid the digit \(2\). But \(000\) is really \(0\), which is not in \(1\) to \(999\), so toss it and you have \(728\) numbers with no \(2\). The total count of numbers is \(999\). Now you only need one subtraction.
Show the full solution
Count the numbers with no \(2\) instead. Write every number as three slots, so \(7\) is \(007\) and \(52\) is \(052\). A slot dodging the \(2\) has \(9\) choices, giving \(9\times9\times9=729\) strings from \(000\) to \(999\). Drop \(000\), which stands for \(0\) and is not in the range, leaving \(728\). There are \(999\) numbers in all, so $$999 - 728 = 271,$$ and \(\boxed{271}\) of them have at least one \(2\). Counting the \(2\)s head on means overlapping cases, since a number can carry two or three of them. Counting the other side avoids all of that.

Practice these ideas

Practice
A small sundae has \(5\) flavor choices. A large has \(5\) flavors and \(2\) sauces. How many different sundaes can you order?
Show the solution
A small sundae is just a flavor, so there are \(5\) of them. A large is a flavor and a sauce, so \(5\times2=10\). No sundae is both sizes, so add, $$5+10=15.$$ There are \(\boxed{15}\) different sundaes. Multiply inside a case, add across the cases.
Practice
A code is \(1\) or \(2\) symbols long, each from \(5\) shapes, with repeats allowed. How many possible codes are there?
Show the solution
Split by length. A \(1\)-symbol code has one slot with \(5\) shapes, so \(5\) codes. A \(2\)-symbol code has two slots with \(5\) shapes each, so \(5^2 = 25\) codes. A code has exactly one length, so add, $$5 + 25 = 30.$$ There are \(\boxed{30}\) possible codes. When the things you are counting come in different lengths, one multiply cannot reach them all. Split by length first.
Practice
Every whole number from \(1\) to \(99\) is written out. How many digits are written in total?
Show the solution
Split by how many digits a number has. The numbers \(1\) to \(9\) are \(9\) numbers with one digit each, so \(9\) digits. The numbers \(10\) to \(99\) are \(90\) numbers with two digits each, so \(90\times2=180\) digits. Adding, $$9+180=189,$$ so \(\boxed{189}\) digits are written. A \(7\) costs one digit and a \(53\) costs two, so there is no single length to multiply by.
Practice
Using pennies, nickels, and dimes (any amounts, including zero), how many ways can you make \(30\) cents?
Show the solution
Case on the number of dimes, which can be \(0\), \(1\), \(2\), or \(3\). Once the dimes and nickels are chosen the pennies are forced, so only the nickels need counting. With \(30\) cents left you can use \(0\) up to \(6\) nickels, which is \(7\) ways. With \(20\) cents left, \(0\) up to \(4\) nickels, which is \(5\) ways. With \(10\) cents left, \(3\) ways. With \(0\) cents left, \(1\) way. Adding, $$7 + 5 + 3 + 1 = 16,$$ so there are \(\boxed{16}\) ways. Split on the biggest coin. It has the fewest possible values, so it pins the rest down fastest.
Practice
How many ordered pairs of positive integers \((a,b)\) satisfy \(a^2 + b < 15\)?
Show the solution
Case on \(a\). Since \(b\) is at least \(1\), we need \(a^2 < 14\), so \(a\) can only be \(1\), \(2\), or \(3\). With \(a=1\) we need \(b<14\), so \(b\) runs \(1\) to \(13\), which is \(13\) pairs. With \(a=2\), \(b<11\) gives \(10\) pairs. With \(a=3\), \(b<6\) gives \(5\) pairs. Adding, $$13 + 10 + 5 = 28,$$ so there are \(\boxed{28}\) pairs. Checking which \(a\) are even possible first keeps the case list short and stops you from hunting past \(a=3\).
Practice
How many two-digit numbers have a units digit strictly greater than the tens digit?
Show the solution
Case on the tens digit \(t\). The units digit must be bigger, so it runs from \(t+1\) up to \(9\), which is \(9-t\) choices. That gives \(8\) when \(t=1\), \(7\) when \(t=2\), and so on down to \(1\) when \(t=8\), with nothing left at \(t=9\). Adding, $$8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 = 36,$$ so there are \(\boxed{36}\) such numbers. Each case count shrinks by one, so the whole total is just \(1\) through \(8\) added up.
Practice
How many three-digit numbers have a hundreds digit that is at least \(2\) times the tens digit?
Show the solution
Case on the tens digit \(t\), with the units digit free at \(10\) choices throughout. We need the hundreds digit \(h\) from \(1\) to \(9\) with \(h \ge 2t\). For \(t=0\) all \(9\) work. For \(t=1\) we need \(h\ge2\), so \(8\) work. For \(t=2\) we need \(h\ge4\), so \(6\). For \(t=3\) we need \(h\ge6\), so \(4\). For \(t=4\) we need \(h\ge8\), so \(2\). From \(t=5\) on you would need \(h\ge10\), which no digit reaches. So $$(9+8+6+4+2)\times 10 = 29 \times 10 = 290,$$ giving \(\boxed{290}\) numbers. The units digit never appears in the rule, so pull its \(10\) choices out and multiply them in at the end.
Practice
How many three-digit numbers have a hundreds digit equal to the sum of the tens and units digits?
Show the solution
Case on the hundreds digit \(h\), which runs from \(1\) to \(9\). With \(h\) fixed, the tens digit can be anything from \(0\) up to \(h\) and the units digit is forced to be whatever is left, so that is \(h+1\) ways. Adding over \(h=1\) through \(h=9\), $$2 + 3 + 4 + \cdots + 10 = 54,$$ so there are \(\boxed{54}\) numbers. Split on the digit the rule pins down. Here \(h\) sets the target sum, and then one choice forces the other.
Practice
Box 1 has \(8\) cards, Box 2 has \(6\). Pick a box, then draw \(2\) cards in order without replacement. How many ordered draws are possible?
Show the solution
Split by box. Box 1 has \(8\) cards, so \(8\times 7 = 56\) ordered draws. Box 2 has \(6\) cards, so \(6\times 5 = 30\). A draw comes from one box only, so add, $$56 + 30 = 86.$$ There are \(\boxed{86}\) ordered draws. The second factor drops by one because the first card is not put back.
Practice
How many four-digit numbers have exactly one digit equal to \(0\)?
Show the solution
The thousands digit is never \(0\), so the lone \(0\) sits in the hundreds, tens, or ones spot, which gives \(3\) cases. Take the \(0\) in the hundreds spot. The thousands digit has \(9\) choices, and the tens and ones must each be nonzero for \(9\) choices each, so that case is \(9 \times 9 \times 9 = 729\). The other two cases work out the same, so $$3 \times 729 = 2187,$$ giving \(\boxed{2187}\) numbers. A number lands in one case only, decided by where its single \(0\) sits. When every case is the same size, adding them is just multiplying by the number of cases.
Practice
How many whole numbers from \(1\) to \(500\) have at least one digit equal to \(7\)?
Show the solution
Count the numbers with no \(7\) instead. Write each number from \(0\) to \(499\) as three slots. The hundreds slot is \(0\) through \(4\) and none of those is a \(7\), so \(5\) choices, while the tens and ones slots each have \(9\) choices once \(7\) is banned. That is \(5 \times 9 \times 9 = 405\) strings. One of them is \(000\), which is outside our range, but \(500\) has no \(7\) and belongs in the pile, so the two adjustments cancel and $$405 - 1 + 1 = 405$$ numbers from \(1\) to \(500\) avoid the digit \(7\). Everything else has one, so $$500 - 405 = 95,$$ giving \(\boxed{95}\) numbers. Counting the \(7\)s head on means overlapping cases, since \(77\) would get caught twice. Counting the other side sidesteps that.
Practice
A 3-character code has exactly one digit (\(10\) choices) and two letters (\(26\) choices each). How many such codes are there?
Show the solution
Split on which spot holds the digit, which gives \(3\) cases. With the digit first, that spot has \(10\) choices and the two letter spots have \(26\) each, so \(10 \times 26 \times 26 = 6760\) codes. The digit in the second or third spot gives \(6760\) each as well, so $$3 \times 6760 = 20280,$$ giving \(\boxed{20280}\) codes. Every code has its digit in exactly one spot, so the three cases do not overlap and nothing is counted twice.
Practice
How many three-digit numbers have digits that add up to \(4\)?
Show the solution
Case on the hundreds digit \(h\), which must be at least \(1\) and at most \(4\) or the sum overshoots. With \(h\) fixed, the tens and units digits must add to \(4-h\), and a target sum of \(s\) allows \(s+1\) pairs, since the tens digit runs \(0\) up to \(s\) and the units digit is forced. So \(h=1\) gives \(4\) ways, \(h=2\) gives \(3\), \(h=3\) gives \(2\), and \(h=4\) gives \(1\). Adding, $$4+3+2+1=10,$$ so there are \(\boxed{10}\) numbers. Split on the most cramped digit. The hundreds digit is squeezed from both sides here, which keeps the case list to four.
Practice
How many ordered pairs of positive integers \((a, b)\) satisfy \(a + b^2 < 20\)?
Show the solution
Case on \(b\), since the rule rearranges to \(a < 20 - b^2\). With \(b=1\) we need \(a<19\), so \(18\) values. With \(b=2\), \(a<16\) gives \(15\). With \(b=3\), \(a<11\) gives \(10\). With \(b=4\), \(a<4\) gives \(3\). At \(b=5\) we have \(b^2=25\), already too big on its own, so the cases stop. Adding, $$18 + 15 + 10 + 3 = 46,$$ so there are \(\boxed{46}\) pairs. Split on the squared variable, because it is the one that eats the room fastest and so gives the fewest cases.