Problem Solving
1.1 Problem Solving and Sums
Problem Solving
The overall objective of this section is to begin thinking about how to solve problems. This is a fundamental idea to the course and underlines everything we do here. There will be several different ideas, seemingly disjoint at times, but the focus is on the problem solving itself. Nothing is assumed of your knowledge here beyond simple arithmetic. If at any point you feel lost in the arithmetic, take a step back and focus on the problem solving method presented here.
The Game of Nim
Here's a game you can play right now with a friend. Gather a pile of stones, or pennies, or anything, and take turns removing 1, 2, or 3 objects. The person who takes the last stone wins. If it's your turn and there's nothing left, you lose.
Adam and April play a few rounds with 21 stones. No matter who goes first, April keeps winning. Adam doesn't think she's cheating. Something is going on. Below is a sample game.
| Heap | Move |
|---|---|
| 21 | Game begins |
| 20 | Adam took 1 |
| 18 | April took 2 |
| 15 | Adam took 3 |
| 12 | April took 3 |
| 9 | Adam took 3 |
| 8 | April took 1 |
| 7 | Adam took 1 |
| 4 | April took 3 |
| 3 | Adam took 1 |
| 0 | April took the rest, Adam loses |
What should Adam do to figure out what's happening?
Pólya's Problem Solving Method
George Pólya (1887–1985) was a Hungarian-American mathematician who spent decades thinking about how people solve problems. He noticed that while every problem is a little different, the process of attacking a problem tends to follow the same four steps.
Fact: Pólya's Four Steps
- Understand the problem.
- Devise a plan.
- Carry out the plan.
- Look back and reflect.
Step 1 - Understand the Problem
This sounds obvious, but it's where most people stumble. Before you do anything else, make sure you know what you're being asked.
Ask yourself:
- What is actually being asked?
- What do I already know? What don't I know?
- What variables are involved?
- Does this remind me of a problem I've seen before?
Example: Understand the Nim problem
Apply Pólya's first step to the game of Nim.
Show Solution
There seems to be a definite winning strategy, some number of stones to take depending on the current pile size. The relevant variables are:
- Starting heap size
- Current heap size
- Whose turn it is
- How many stones you're allowed to take (1, 2, or 3)
Step 2 - Devise a Plan
Once you understand the problem, you need an approach. Here are some useful strategies:
- Make a list or organize data into a table.
- Draw a picture.
- Assign variables to unknown quantities.
- Rule out the unlikely options.
- Guess and check.
- Solve a simpler related problem first.
Example: Devise a plan for Nim
What plan would you use to figure out the winning strategy?
Show Solution
- Record what happens in several games and look for patterns.
- Start simpler: what if the heap only had 1 stone? 2? 3? 4?
- Does the winner always leave a specific number for the opponent?
Step 3 - Carry Out the Plan
Adam notices April always ends her turn on an even number. He tries ending on even numbers too... he still loses.
4. Give up.
Fact: Don't throw away failed attempts
If your plan doesn't work, go back to step 2 and improve it. Failed attempts are data.
Adam then guesses that the key might be to leave a multiple of 4 for his opponent. He tries it and wins his first game!
Step 4 - Look Back and Reflect
After you find a solution, check it.
- Does the answer make sense?
- Can you solve it a different way and get the same result?
- Can your approach be generalized or used on other problems?
- How would the problem change if the rules also allowed taking 4 stones?
Example: Test the Nim strategy
Play more games using the "leave a multiple of 4" strategy. Can you always win if you go first? What if you go second?
MyOpenMath: Win your own game of Nim
Gauss' Problem
As the lore goes: a teacher, fed up with a noisy third-grade class, punishes them by telling them to add up all the numbers from 1 to 100. No calculators. A young student named Carl Friedrich Gauss hands in the answer almost immediately. The teacher, skeptical, checks it and it's right. Confused by how Gauss calculated this so quickly, she wonders how he could have solved this problem so quickly.
Example: Gauss's pairing trick
Find $1 + 2 + 3 + \cdots + 100$.
Show Solution
Gauss noticed that if you pair the first and last terms, you always get 101:
$$1 + 100 = 101, \quad 2 + 99 = 101, \quad 3 + 98 = 101, \quad \ldots$$
There are exactly 50 such pairs, so:
$$1 + 2 + \cdots + 100 = 50 \times 101 = 5050$$
Gauss' pairing trick is nice, but it runs into a problem when there are an odd number of terms in the sum. Consider:
$$1+2+3+4+5$$
We could pair up $1+5=6$ and $2+4=6$, but that 3 is left without a partner. Is this a problem that we can solve?
Example: An algebraic version of the same trick
Find $1 + 2 + 3 + \cdots + 100$ using algebra.
Show Solution
Call the sum $S$. Write it twice: once forwards, once backwards, and add them:
$$S = 1 + 2 + 3 + \cdots + 99 + 100$$ $$S = 100 + 99 + 98 + \cdots + 2 + 1$$ $$2S = 101 + 101 + 101 + \cdots + 101 + 101$$
This method forces there to be an even number of terms in the sum. In this case, there are 100 copies of 101, so $2S = 100 \cdot 101 = 10100$, which gives $S = 5050$.
This same trick works for any ending number $n$. Replace 100 with $n$:
$$2S = n(n+1) \implies S = \frac{n(n+1)}{2}$$
Definition: Triangular Numbers
The sum of the first $n$ natural numbers is called the $n$th triangular number, written $t_n$:
$$1 + 2 + 3 + \cdots + n = t_n = \frac{n(n+1)}{2}$$
Triangular numbers are called triangular because their dots can be arranged into triangles.
| $t_1 = 1$ | $t_2 = 3$ | $t_3 = 6$ | $t_4 = 10$ |
|---|---|---|---|
| • | • | • | • |
| • • | • • | • • | |
| • • • | • • • | ||
| • • • • |
Example: Find triangular sums
Find each of the following sums.
- $1 + 2 + 3 + \cdots + 48$
- $1 + 2 + 3 + \cdots + 399$
Show Solution
Use $t_n = \frac{n(n+1)}{2}$.
- The first sum is the 48th triangular number: $$t_{48} = \frac{48 \cdot 49}{2} = \frac{2352}{2} = 1176$$
- This one is the 399th triangular number: $$t_{399} = \frac{399 \cdot 400}{2} = \frac{159600}{2} = 79800$$
MyOpenMath: Triangular Number Practice
Example: Sums that don't start at 1
Find $5 + 6 + 7 + \cdots + 23$.
Show Solution
This isn't quite a triangular number since it doesn't start at 1. One trick: add up $1$ through $23$, then subtract $1$ through $4$ (the part we don't want).
$$t_{23} - t_4 = \frac{23 \cdot 24}{2} - \frac{4 \cdot 5}{2} = 276 - 10 = 266$$
MyOpenMath: Triangular Number Practice 2
Example: Even and multiples sums
Find $2 + 4 + 6 + \cdots + 100$.
Show Solution
Factor a 2 out of every term to find a triangular number hidden in the sum!
$$2(1 + 2 + 3 + \cdots + 50) = 2 \cdot t_{50} = 2 \cdot \frac{50 \cdot 51}{2} = 50 \cdot 51 = 2550$$
MyOpenMath: Triangular Number Practice 3
Matchsticks and Patterns
Sometimes the best way to work through a problem is to build a table and look for a pattern.
Example: Triangle matchstick pattern
A triangle pattern is built with matchsticks. Figure 1 has 1 triangle made with 3 matchsticks, Figure 2 has 2 triangles made with 5 matchsticks (they share a side), and so on. How many matchsticks are in the 4th figure? The 10th? The 50th?
Show Solution
Sometimes when presented with a difficult problem it can be useful to just to collect data and present it in an organized way. Try building up a table:
| Figure | Sticks |
|---|---|
| 1 | 3 |
| 2 | 5 |
| 3 | 7 |
| 4 | 9 |
Each time we add a triangle we add 2 matchsticks. The 4th figure has 9 sticks.
For larger figures, notice the pattern: Figure 1 starts with 3 sticks, and each new figure adds 2.
| Figure | Process | Sticks |
|---|---|---|
| $1$ | $3$ | $3$ |
| $2$ | $3 + 2(1)$ | $5$ |
| $3$ | $3 + 2(2)$ | $7$ |
| $4$ | $3 + 2(3)$ | $9$ |
| $\vdots$ | $\vdots$ | $\vdots$ |
| $n$ | $3 + 2(n-1)$ | $1 + 2n$ |
The 10th figure: $1 + 2(10) = 21$ sticks.
The 50th figure: $1 + 2(50) = 101$ sticks.
In general, our nth figure will have $1 + 2n$ sticks.
MyOpenMath: Matchstick Pattern Practice
The Magic Square
A magic square is a square grid with numbers in each cell, but each column, row, and diagonal need to add up to the same number. That number is called the magic number.
| 17 | 3 | 13 |
| 7 | 11 | 15 |
| 9 | 19 | 5 |
In the magic square above, the top row sums to $17+3+13=33$. So does every other row, column, and diagonal. Check them!
Example: Find the magic number
Consider the following 4x4 magic square. What is its magic number?
| 16 | 2 | 3 | 13 |
| 5 | 11 | 10 | 8 |
| 9 | 7 | 6 | 12 |
| 4 | 14 | 15 | 1 |
Show Solution
Picking any row or column should do. Lets pick the first column.
$$16+5+9+4=34$$
The magic number must be 34.
If we were to construct a magic square from scratch, using the numbers 1 through 9, how might you go about creating it? Think back on our problem solving method. What might you do first?
Example: Find the magic number
What must every row, column, and diagonal add up to in a 3×3 magic square using 1–9?
Show Solution
If every row adds up to some magic number $m$, then the total of all three rows is $3m$.
| a | b | c |
| d | e | f |
| g | h | i |
$a+b+c=m$, $d+e+f=m$, and $g+h+i=m$. If we add all of the numbers together, we get $3m$.
But that total is also just the sum of all numbers 1 through 9:
$$t_9 = \frac{9 \cdot 10}{2} = 45$$
So $3m = 45$, which means $\mathbf{m = 15}$.
Example: Completing the square
Now that we know what the magic number should be, build a magic square.
Show Solution
So we could start placing numbers randomly in the magic square to try and hit the magic number, but there are many possible combinations to check. Trial and error might not be best here. Let's look at all the ways to write 15 as a sum of three distinct numbers from 1–9:
$$9+5+1, \quad 9+4+2, \quad 8+6+1, \quad 8+5+2, \quad 8+4+3$$ $$7+6+2, \quad 7+5+3, \quad 6+5+4$$
Count how many times each number appears across these sums:
| Number | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|---|---|---|---|---|---|---|---|---|
| Times used | 2 | 3 | 2 | 3 | 4 | 3 | 2 | 3 | 2 |
5 appears 4 times, the most. The center square participates in a row, a column, and both diagonals (4 sums total), so 5 goes in the center.
2, 4, 6, 8 each appear 3 times. Corner squares participate in a row, a column, and one diagonal (3 sums), so the even numbers go in the corners.
1, 3, 7, 9 appear only twice, they go in the edges.
With 5 in the center, placing 2 in a corner forces the opposite corner to be 8 (since $2 + 5 + 8 = 15$). Placing 3 in an adjacent corner forces 7 on the other side. The remaining numbers fall into place:
| 2 | 7 | 6 |
| 9 | 5 | 1 |
| 4 | 3 | 8 |
You can verify: every row, column, and diagonal sums to 15. This isn't the only magic square of this size and given numbers. How might you make another?