Monday, March 21, 2011

Mathematical Monday: Video Game Riddles - Solutions

Here are the solutions to my favorite math riddles I've encountered in video games, which I shared last week. If you missed them, give them a try before you look at the solutions!

1. Circus tent genie in Waukeen's Promenade, Baldur's Gate II: Shadows of Amn
The princess is as old as the prince will be when the princess is twice as old as the prince was when the princess's age was half the sum of their present ages. How old are the prince and princess? My addition: Given that the princess is a teenager, and assuming only whole number ages.
The hard part of this riddle is parsing it, but if you look at it carefully, it gives information about the prince and princess's ages at three different times--past, present, and future--which I've color-coded. Let's call the current age of the princess X and that of the prince Y. Their ages at the past time described are simply X and Y minus a certain number of years (which we'll call P), and their ages at the future time described are simply X and Y plus a different number of years (which we'll call F). For example, the prince's age at the future time described is Y+F. So we can make equations describing the relationships in the riddle.
The princess is as old as the prince will be:
(1) X=Y+F
when the princess is twice as old as the prince was:
(2) X+F = 2*(Y-P)
when the princess's age was half the sum of their present ages:
(3) X-P = 0.5*(X+Y)
This gives us three equations with four unknowns, so we won't be able to solve for exact numbers. But we can find out the relationship between X and Y. Choose your favorite method for solving the system of equations, and you should eventually find that 3X/4 = Y. So the prince's age is three quarters of the princess's age. Given my addition to the problem--that the princess is a teenager and we're considering whole number ages only--not only must the princess be a "teen" but her age must evenly divide by four. This means the princess is 16, and the prince is 12.

2. Yuan-Ti in Mutamin's Challenge, Neverwinter Nights
After slaying a dragon, a group of knights gave some of the trinkets from its treasure stash to a group of fewer than ten girls to divide. While the trinkets could have been divided equally amongst the girls, they argued over how to divide it. One suggested that they divide it by family instead of by individual. In the group there were two groups of two sisters, the rest unrelated. This division would mean that the trinkets per family were five more than the trinkets per girl. Before a decision was made, one girl said she desired nothing. So her share was divided amongst the others. The shares were equal again. The suggestion of dividing the trinkets per family was withdrawn, as all were satisfied. How many girls shared in the division and how many did each get?
Assuming that all of the relevant numbers in this problem are integers greater than zero--which I will refer to as "counting numbers"--so there are no negative trinkets or half girls, there is actually only one solution to the problem regardless of whether or not it is specified that there are fewer than ten girls. Consider it a bonus hint to help solve the problem. Here is my method:
The number of trinkets (T) divides evenly by the number of girls (G) and the number of families, which is G-2 (because there are two pairs of sisters, essentially eliminating two girls from the count). Since T is a multiple of G, let's say that T = k*G, where k is some counting number. The number of trinkets per family (T/[G-2]) is five more than the number of trinkets per girl (T/G). In other words,
T/G + 5 = T/(G-2)
Substituting in T = kG and solving for G gives
G = 2 + 2k/5
Since k must be a multiple of 5 to keep G an integer, we can try out a few values of k and see what happens. Setting k equal to 5, 10, 15, and 20 give G values of 4, 6, 8, and 10, respectively. G must be less than 10 but also greater than 4, since there have to be more than just the two pairs of sisters. So are there 6 or 8 girls? The number of trinkets must also be evenly divisible by G-1, corresponding to the final division of trinkets when the one girl opts out. If G=8 and k=15, then T=120, but that's not divisible by 7. If G=6 and k=10, then T=60 which is divisible by 5: 60/5 = 12. And there's our answer: 5 girls split the 60 trinkets, getting 12 each.

I promised that this was the only solution even if the problem didn't give us the hint that there are fewer than 10 girls. So here's a more explicit way to complete the problem. It's actually much harder this way, so consider yourself warned.
We know that T divides evenly by G, G-1, and G-2. How can we use that to define T? T could be a multiple of G*(G-1)*(G-2), of course, as that would guarantee that it is divisible by all three values. But if there is an overlap in the factors of those three values, T could be G*(G-1)*(G-2) divided by those factors and still be a multiple of all three values (Example: 2*3*8 = 48, but since 8 and 2 both have 2 as a factor, the smallest multiple of all three of those is 48/2 = 24). Still with me? Since our three values are consecutive integers, the only number they can possibly share as a factor is 2--that is, if G and G-2 are both even numbers. Right? This all comes down to allowing us to define
T = d*G(G-1)(G-2)/2
where d is a counting number. From before, we have that T = kG and G = 2+2k/5, but since we know that k has to be a multiple of 5, I'm going to define yet another counting number b such that k = 5*b. This means T = 5bG and G = 2 + 2b, which get substituted into the T = d*... equation. Solve for b to find
b = 5/(2d) - 1/2
The only way both d and b can be counting numbers is if d = 1! d = 2, 3, and 4 give non-integer b values, d = 5 makes b zero, and d>5 makes b negative. It all falls into place from there.
d = 1
b = 5/2 - 1/2 = 2
G = 2+2b = 6
T = 5bG = 60
G-1 = 5
T/(G-1) = 12
We have a unique answer! 5 girls get 12 trinkets each.

3. Battle droids on Tattooine, Star Wars: Knights of the Old Republic
What are the next two entries in the sequence?
14 * 11-14 * 31-14 * 13-21-14 * _____ * _____
The math in this one is so simple, it's kind of infuriating how long I spent trying to solve it. Read the individual digits of each entry out loud:
one four * one one, one four * three one, one four * one three, two one, one four
Get it? Each entry describes the digits in the entry before it, in order of the digits' first appearance. The first entry has one one, and one four, so the second entry is 11-14. So, since the last entry has three ones, one three, one two, and one four, the next entry is
and the entry after that is
Sweet and simple, with math that a kindergartener would understand, but it can stump even advanced math users. Always fun.

A few other great video game math puzzles come to mind, but they're not riddles so much as puzzles that involve manipulation of objects, so they're harder to share here. Then there are mini-games like Pazaak in KotOR that involve math (but chance as well, so there's less to solve). In any case, I love math and I love computer RPGs, so when the two cross over I am always delighted. I hope you enjoyed these, too!


GlennFromIowa said...

I'm sorry, this post is kinda (ok, really) old, but I hafta mention that the answer to #3 is wrong. I got carried away and didn't group the digits. But given the explanation, the next two entries should be these: 31-13-12-14 * 23-41-12-14. I thought the first (next entry) was a typo, but then the entry after that was based on the incorrect numbers, not the preceding (correct) spelled-out digits.

I don't play KotOR, but it almost makes me wanna start, just so I can see what answer the game accepts. :p Otherwise, I enjoyed reading some of your posts. I started with the post on the Ewok Line and got sucked in from there. :)

Eleni said...

Haha, you're right, that's exactly what happened. The game had the correct answer, it was just my reproduction where I made the mistake.

That game's an oldie but a goodie. I miss it.