One Potato, Two Potato, … Mathematics of Elimination John A. Frohliger St. Norbert College.

Presentation on theme: "One Potato, Two Potato, … Mathematics of Elimination John A. Frohliger St. Norbert College."— Presentation transcript:

One Potato, Two Potato, … Mathematics of Elimination John A. Frohliger St. Norbert College

Selecting Someone to be “It” Stand around in a circle and go from person to person chanting, “One potato, two potatoes, three potatoes, four, five potatoes, six potatoes, seven potatoes, more.” Whoever was indicated when we got to “more” was out of the circle. Continue playing “One Potato” in this manner until only one person was left. That person was “It.”

Problem 338 inThe Amazing 1000 Puzzle Challenge 2 (Carlton Books ) Decimated In Roman times, soldiers who were to be punished were forced to form a line, and every tenth one was executed. This is the origin of the word “decimate.” If you were one of 1000 soldiers lined up in a circle, with every second soldier being executed until only one remained, in which position would you want to be in order to survive?

Solution in the Back (You want to start in position) 976. Take 2 to the power of 10, which gives you the lowest number above 1000. 2 10 = 1024 Then use the formula. 1024 – 2(1024 – 1000) = 976

The “Original” Version The Josephus Problem Flavius Josephus, first century Jewish historian. According to legend, during the Jewish-Roman war, Josephus and forty soldiers were trapped by the Roman army. They decided to commit suicide instead of surrendering to the Romans. Their plan was to form a circle and kill every third one until none remained.

The “Original” Version The Josephus Problem Josephus did not want to die, so he figured out which position would be the last one standing and took that position. Once he was the only one left, he allowed himself to be captured by the Romans.

Generalized Problem Suppose you have n people in a circle. Pick a number m. Go around removing every m th person until only one remains. Where was that person in the original circle?

Notation for Finding the Solution Number the people from 1 to n. Start the count at Person 1. Let R(n, m) be the number of the person (in the original lineup) who remains until the end if we remove every m th person. We want to find R(n, m).

Example Start with n = 9 people. Remove every m = 3 nd person. Find R(9, 3), the number of the last person remaining.

n = 9, m = 3 1 2 3 4 56 7 8 9

1 2 4 56 7 8 9

1 2 4 5 7 8 9

1 2 4 5 7 8

1 2 5 7 8

1 2 5 7

1 2 7

1 7

1 Conclusion: R(9, 3) = 1

New Example Find R(10, 3). (Same example as before, with n raised from 9 to 10) Start with n = 10 people. Remove every m = 3 d person.

n = 10, m = 3 1 2 3 4 5 6 7 8 9 10

n = 10, m = 3 1 4 5 6 7 8 9 10 Remove the m = 3 d person. 2

n = 10, m = 3 1 4 5 6 7 8 9 10 Instead of continuing as before, 2

n = 10, m = 3 1 8 4 1 5 2 6 36 3 7 4 8 5 9 6 10 7 Instead of continuing as before, renumber the remaining 9 people, starting at the next person. Old Number New Number Old Number New Number 2 9

n = 10, m = 3 Note: The original number for each person is m = 3 more than the new number 1 8 4 1 5 2 6 36 3 7 4 8 5 9 6 10 7 2 9 Old Number New Number Old Number New Number

n = 10, m = 3 Note: The original number for each person is m = 3 more than the new number ALMOST 1 8 4 1 5 2 6 36 3 7 4 8 5 9 6 10 7 2 9 Old Number New Number Old Number New Number

n = 10, m = 3 We know from the n = 9, m = 3 example, that the last remaining person is the one newly numbered R(9, 3) = 1. 4 1 Old Number New Number Old Number New Number

n = 10, m = 3 We know from the n = 9, m = 3 example, that the last remaining person is the one newly numbered R(9, 3) = 1. 4 1 Conclusion: The person was originally in the spot 4. R(10, 3) = 4 = 1 + 3 = R(9, 3) +3

Key for Finding R(n, m) for n > 1 Start with n people, numbered 1 thru n. 1 2 3  m - 1 m m + 1 m + 2 n n - 1 

Key for Finding R(n, m) for n > 1 Start with n people, numbered 1 thru n. Remove Person m. 1 2 3  m - 1 m + 1 m + 2 n n - 1 

Key for Finding R(n, m) for n > 1 Start with n people, numbered 1 thru n. Remove Person m. There are now n – 1 people remaining 1 2 3  m - 1 m + 1 m + 2 n n - 1 

Key for Finding R(n, m) for n > 1 Renumber them 1 thru (n - 1), starting at the next person in line. 1 2 3  m – 1 n - 1 m + 1 1 m + 2 2 n n - 1  Old Number New Number Old Number New Number

Key for Finding R(n, m) for n > 1 Renumber them 1 thru (n - 1), starting at the next person in line. Old Number = New Number + m Old Number New Number Old Number New Number 1 2 3  m – 1 n - 1 m + 1 1 m + 2 2 n n - 1 

Key for Finding R(n, m) for n > 1 Renumber them 1 thru (n - 1), starting at the next person in line. Old Number = New Number + m ALMOST Old Number New Number Old Number New Number 1 2 3  m – 1 n - 1 m + 1 1 m + 2 2 n n - 1 

Key for Finding R(n, m) for n > 1 Of the remaining n – 1 people, the last person standing has new number R(n – 1, m). m + 1 1 m + 2 2 Last Person Standing R(n - 1, m)  Old Number New Number Old Number New Number

Key for Finding R(n, m) for n > 1 The last person was originally in position R(n, m) = R(n – 1, m) + m m + 1 1 m + 2 2 Last Person Standing R(n - 1, m) R(n, m)  Old Number New Number Old Number New Number

Key for Finding R(n, m) for n > 1 The last person was originally in position R(n, m) = R(n – 1, m) + m ALMOST m + 1 1 m + 2 2 Last Person Standing R(n - 1, m) R(n, m)  Old Number New Number Old Number New Number

Let’s get rid of the “ALMOST” part.

Go back to n = 10, m = 3 1 2 3 4 5 6 7 8 9 10

n = 10, m = 3 1 4 5 6 7 8 9 10 Remove person from Position m = 3. 2

n = 10, m = 3 1 8 4 1 5 2 6 3 7 4 8 5 9 6 10 7 After we renumber the people, all of the old numbers are m = 3 more than the new, except … 2 9

n = 10, m = 3 After we renumber the people, all of the old numbers are m = 3 more than the new, except … 1 8 4 1 5 2 6 3 7 4 8 5 9 6 10 7 2 9 … New Position 8 was Old Position 1 and New Position 9 was Old Position 2.

n = 10, m = 3 … New Position 8 was Old Position 1 and New Position 9 was Old Position 2. After we renumber the people, all of the old numbers are m = 3 more than the new, except … 1 8 4 1 5 2 6 3 7 4 8 5 9 6 10 7 2 9 To make sense of this, we need to talk about …

Modular Arithmetic Start with a positive integer k. In arithmetic mod k, the numbers are 1, 2, 3, …, k. You don’t list 0, negative numbers or numbers greater than k.

Modular Arithmetic Start with a positive integer k. In arithmetic mod k, the numbers are 1, 2, 3, …, k. You don’t list 0, negative numbers or numbers greater than k. To add numbers i and j, modulo k, 1.First find i + j.

Modular Arithmetic Start with a positive integer k. In arithmetic mod k, the numbers are 1, 2, 3, …, k. You don’t list 0, negative numbers or numbers greater than k. To add numbers i and j, modulo k, 1.First find i + j. 2.If i + j ≤ k, the answer is (i + j)(mod k) = i + j.

Modular Arithmetic Start with a positive integer k. In arithmetic mod k, the numbers are 1, 2, 3, …, k. You don’t list 0, negative numbers or numbers greater than k. To add numbers i and j, modulo k, 1.First find i + j. 2.If i + j ≤ k, the answer is (i + j)(mod k) = i + j. 3.If i + j > k, the answer is (i + j)(mod k) = i + j - k

Example with k = 12 The numbers are 1, 2, 3, …, 11, 12.

Example with k = 12 The numbers are 1, 2, 3, …, 11, 12. (3 + 7)(mod 12) = 10

Example with k = 12 The numbers are 1, 2, 3, …, 11, 12. (3 + 7)(mod 12) = 10 (9 + 7)(mod 12) = 16 – 12 = 4

Example with k = 12 The numbers are 1, 2, 3, …, 11, 12. (3 + 7)(mod 12) = 10 (9 + 7)(mod 12) = 16 – 12 = 4 Hey, you’ve done this before!

Math on a Clock The numbers are 1, 2, 3, …, 11, 12.

Math on a Clock The numbers are 1, 2, 3, …, 11, 12. 7 hours after 3 o’clock, the time is (3 + 7)(mod 12) = 10 o’clock.

Math on a Clock The numbers are 1, 2, 3, …, 11, 12. 7 hours after 3 o’clock, the time is (3 + 7)(mod 12) = 10 o’clock. 7 hours after 9 o’clock, the time is (9 + 7)(mod 12) = 16 – 12 = 4 o’clock.

One more time with n = 10, m = 3 1 2 3 4 5 6 7 8 9 10

One more time with n = 10, m = 3 1 4 5 6 7 8 9 10 Remove person from Position m = 3. 2

One more time with n = 10, m = 3 1 8 4 1 5 2 6 3 7 4 8 5 9 6 10 7 After we renumber the people, all of the old numbers are m = 3 more than the new … 2 9

One more time with n = 10, m = 3 1 8 4 1 5 2 6 3 7 4 8 5 9 6 10 7 After we renumber the people, all of the old numbers are m = 3 more than the new … … mod 10! 2 9 (8 + 3)(mod 10) = 1

One more time with n = 10, m = 3 1 8 4 1 5 2 6 3 7 4 8 5 9 6 10 7 After we renumber the people, all of the old numbers are m = 3 more than the new … … mod 10! 2 9 (9 + 3)(mod 10) = 2

“Almost” Formula for R(n, m) For n > 1, R(n, m) = R(n – 1, m) + m

Actual Formula for R(n, m) For n > 1, R(n, m) = (R(n – 1, m) + m)(mod n)

Disclaimer for Those Who Already Knew Modular Arithmetic Frequently, in arithmetic mod k, the numbers used are 0, 1, … k – 1, instead of 1, 2, 3, …, k. To add numbers i and j, modulo k, First find i + j. If 0 ≤ i + j < k, the answer is (i + j)(mod k) = i + j ; If k ≤ i + j, the answer is (i + j)(mod k) = i + j – k (*)

Disclaimer for Those Who Already Knew Modular Arithmetic Frequently, in arithmetic mod k, the numbers used are 0, 1, … k – 1, instead of 1, 2, 3, …, k. To add numbers i and j, modulo k, First find i + j. If 0 ≤ i + j < k, the answer is (i + j)(mod k) = i + j ; If k ≤ i + j, the answer is (i + j)(mod k) = i + j – k (*) * Actually, you get (i + j)(mod k) by taking i + j and subtracting enough copies of k until the answer is from 0 to k – 1 (or 1 to k in our case).

Pattern of R(n, 2) In the original problem, n = 1000 and m = 2. Look at the pattern leading up to R(1000, 2). R(2, 2) = 1 (Do it yourself.)

Pattern of R(n, 2) In the original problem, n = 1000 and m = 2. Look at the pattern leading up to R(1000, 2). R(2, 2) = 1 (Do it yourself.) R(3, 2) = (R(2, 2) + 2)(mod 3)

Pattern of R(n, 2) In the original problem, n = 1000 and m = 2. Look at the pattern leading up to R(1000, 2). R(2, 2) = 1 (Do it yourself.) R(3, 2) = (R(2, 2) + 2)(mod 3) = (1 + 2)(mod 3) = 3(mod 3) = 3

Pattern of R(n, 2) In the original problem, n = 1000 and m = 2. Look at the pattern leading up to R(1000, 2). R(2, 2) = 1 (Do it yourself.) R(3, 2) = (R(2, 2) + 2)(mod 3) = (1 + 2)(mod 3) = 3(mod 3) = 3 R(4, 2) = (R(3, 2) + 2)(mod 4)

Pattern of R(n, 2) In the original problem, n = 1000 and m = 2. Look at the pattern leading up to R(1000, 2). R(2, 2) = 1 (Do it yourself.) R(3, 2) = (R(2, 2) + 2)(mod 3) = (1 + 2)(mod 3) = 3(mod 3) = 3 R(4, 2) = (R(3, 2) + 2)(mod 4) = (3 + 2)(mod 4) = 5(mod 4) = 1

Continuing the Pattern n R(n, 2) =(R(n -1,2) + 2)(mod n) 21 33 41 53 65 77 81 9 3 10 5 11 7 12 9 13 11 1413 15 161

The Pattern If n is a power of 2, R(n, 2)=1

The Pattern If n is a power of 2, R(n, 2)=1 If n is not a power of 2, ♦Find the highest power of 2 that is less than n.

The Pattern If n is a power of 2, R(n, 2)=1 If n is not a power of 2, ♦Find the highest power of 2 that is less than n. ♦Starting at that number, count odd numbers until you get to n. That’s R(n, 2)

The Pattern If n is a power of 2, R(n, 2)=1 If n is not a power of 2, ♦Find the highest power of 2 that is less than n. ♦Starting at that number, count odd numbers until you get to n. That’s R(n, 2) ♦That is, if 2 k is the highest power of 2 less than n, R(n, 2) = 2(n – 2 n ) + 1.

Solution to Problem 338 The Amazing 1000 Puzzle Challenge 2 Of the 1000 original soldiers, the last one left was in position R(1000, 2).

Solution to Problem 338 The Amazing 1000 Puzzle Challenge 2 Of the 1000 original soldiers, the last one left was in position R(1000, 2). 1.The highest power of 2 less than 1000 is 2 9 = 512.

Solution to Problem 338 The Amazing 1000 Puzzle Challenge 2 Of the 1000 original soldiers, the last one left was in position R(1000, 2). 1.The highest power of 2 less than 1000 is 2 9 = 512. 2.The last soldier was in position R(1000, 2) = 2(1000 – 512) + 1 = 977

Comparison to Answer in the Book Our Solution: 1.The highest power of 2 less than 1000 is 2 9 = 512. 2.The last soldier was in position R(1000, 2) = 2(1000 – 512) + 1 = 977

Comparison to Answer in the Book Our Solution: 1.The highest power of 2 less than 1000 is 2 9 = 512. 2.The last soldier was in position R(1000, 2) = 2(1000 – 512) + 1 = 977 Book’s Solution: 1.The lowest power of 2 greater than 1000 is 2 10 = 1024. 2.The last soldier was in position 1024 – 2(1024 – 1000) = 976

Comparison to Answer in the Book Our Solution: 1.The highest power of 2 less than 1000 is 2 9 = 512. 2.The last soldier was in position R(1000, 2) = 2(1000 – 512) + 1 = 977 Book’s Solution: 1.The lowest power of 2 greater than 1000 is 2 10 = 1024. 2.The last soldier was in position 1024 – 2(1024 – 1000) = 976 The Book’s Answer is Correct

Comparison to Answer in the Book Our Solution: 1.The highest power of 2 less than 1000 is 2 9 = 512. 2.The last soldier was in position R(1000, 2) = 2(1000 – 512) + 1 = 977 Book’s Solution: 1.The lowest power of 2 greater than 1000 is 2 10 = 1024. 2.The last soldier was in position 1024 – 2(1024 – 1000) = 976 The Book’s Answer is Correct, if you start counting at 0 instead of 1.

Finding R(n, 2) using Base 2 Usually, we write numbers in base 10 (decimal) notation. 2071 2 x 10 3 + 7 x 10 1 + 1

Finding R(n, 2) using Base 2 In base 2, numbers are written as a sequence of 0’s and 1’s. 1101 = 13 (base 10) 1 x 2 3 + 1 x 2 2 + 1

Finding R(n, 2) using Base 2 1.Take n. (1000) 1.Take n in base 2 (111110100)

Finding R(n, 2) using Base 2 1.Take n. (1000) 2.Subtract the highest power of 2 less than n. (1000 – 512 = 488) 1.Take n in base 2 (111110100) 2.Remove the leading 1. (11110100)

Finding R(n, 2) using Base 2 1.Take n. (1000) 2.Subtract the highest power of 2 less than n. (1000 – 512 = 488) 3.Multiply by 2. (2 x 488 = 976) 1.Take n in base 2 (111110100) 2.Remove the leading 1. (11110100) 3.Add a 0 at the end. (111101000)

Finding R(n, 2) using Base 2 1.Take n. (1000) 2.Subtract the highest power of 2 less than n. (1000 – 512 = 488) 3.Multiply by 2. (2 x 488 = 976) 4.Add 1. (976 + 1 = 977) 1.Take n in base 2 (111110100) 2.Remove the leading 1. (11110100) 3.Add a 0 at the end. (111101000) 4.Change the last 0 to 1. (111101001 = 977)

Finding R(n, 2) using Base 2 1.Take n. (1000) 2.Subtract the highest power of 2 less than n. (1000 – 512 = 488) 3.Multiply by 2. (2 x 488 = 976) 4.Add 1. (976 + 1 = 977) 1.Take n in base 2 (111110100) 2.Remove the leading 1. (11110100) 3.Add a 0 at the end. (111101000) 4.Change the last 0 to 1. (111101001 = 977) (Shortcut: Move the 1 from beginning to end.)

R(n, m) for m ≠ 2 n R(n, 3) =(R(n - 1,3) + 3)(mod n) 22 32 41 54 61 74 87 9 1 10 4 11 7 12 10 13 142 155 168

R(n, m) for m ≠ 2 n R(n, 4) =(R(n - 1,4) + 4)(mod n) 21 32 42 51 65 72 86 9 1 10 5 11 9 12 1 13 5 149 1513 161

R(n, m) for various values of n and m

I don’t see nice patterns for m ≠ 2. Do you?

Variation Suppose you are Person 1, and you get to choose the number m.

Variation Suppose you are Person 1, and you get to choose the number m. You want to be the last person standing.

Variation Suppose you are Person 1, and you get to choose the number m. You want to be the last person standing. That is, you want R(n, m) = 1.

Variation Suppose you are Person 1, and you get to choose the number m. You want to be the last person standing. That is, you want R(n, m) = 1. Can you pick the right m?

Yes, if you know n. For instance, if n = 7,

Yes, if you know n. For instance, if n = 7, you could pick m = 11.

But, what if you don’t know how many people are in the circle? Is there some “magic” m that will work no matter how many people you start with? That is, is there an m so that R(n, m) = 1 for every n?

But, what if you don’t know how many people are in the circle? Answer: No, there is no such “magic” number m.

But, what if you don’t know how many people are in the circle? Answer: No, there is no such “magic” number m. For any m, if n happens to be m - 1, then Person 1 is the first person to be eliminated.

But, what if you don’t know how many people are in the circle? Answer: No, there is no such “magic” number m. Example: If you pick m = 6 but there are n = 5 people, you are the first one out.

What if you know roughly how many people there are? Suppose you don’t know exactly what n is, but you know it’s less than some number N. Could you find an m such that R(n, m) = 1 for any such n? For example, can you find a “magic” m if you know n ≤ 10?

m = 2520 works for any n up to 10.

How Did He Do That? If I am Person 1 and there are n people in the circle, I can eliminate the person right before me if I chose m = n

How Did He Do That? If I am Person 1 and there are n people in the circle, I can eliminate the person right before me if I chose m = n or m = 2n

How Did He Do That? If I am Person 1 and there are n people in the circle, I can eliminate the person right before me if I chose m = n or m = 2n or m = 3n

How Did He Do That? If I am Person 1 and there are n people in the circle, I can eliminate the person right before me if I chose m = n or m = 2n or m = 3n or m equals any multiple of n, that is, if m = kn for any positive integer k.

How Did He Do That? After the person before me is eliminated, there are now n - 1 people and the count restarts at me. As before, the next time around, the person before me will be eliminated if m happens to be a multiple of n - 1.

How Did He Do That? After that person is eliminated, there are now n - 2 people remaining and the count restarts at me. Again, the new person before me will be eliminated if m happens to be a multiple of n - 2. And so on...

Moral: If I choose m to be any multiple of n, n - 1, n - 2, …, 3, 2, then each time around, the person right before me is eliminated.

Moral: If I choose m to be any multiple of n, n - 1, n - 2, …, 3, 2, then each time around, the person right before me is eliminated. I will be the last person standing!

Moral: If I choose m to be any multiple of n, n - 1, n - 2, …, 3, 2, then each time around, the person right before me is eliminated. I will be the last person standing! So if I know there are no more than N people in the circle, I can choose m to be any common multiple of N, N -1, N -2, …, 3, 2.

Moral: If I choose m to be any multiple of n, n - 1, n - 2, …, 3, 2, then each time around, the person right before me is eliminated. I will be the last person standing! So if I know there are no more than N people in the circle, I can choose m to be any common multiple of N, N -1, N -2, …, 3, 2. (m = N! works, but it’s pretty big.)

Moral: In our example where n is no bigger than N = 10, a common multiple of 2, 3, …, 10 is m = 5 x 7 x 8 x 9 = 2520.

Things to Think About If you are Person 2 or Person 3, or somebody else, is there a way of finding the right m so that you are the last person standing?

Things to Think About What if, instead of a single static m, it’s a sequence of numbers? For example, if the sequence is 5, 10, 15, …, first you remove the 5 th person, then the 10 th, then the 15 th, and so on. Who is the last one standing?

Things to Think About Is there a “magic” sequence of numbers so that Person 1 is always the last person standing?

Things to Think About Is there a “magic” sequence so that Person 2 (or 3 or …) is the last one standing?

Thank You!

Download ppt "One Potato, Two Potato, … Mathematics of Elimination John A. Frohliger St. Norbert College."

Similar presentations