Tuesday, December 8, 2009

Problem 12 Solution - "Energy Crisis"

Problem 12.1.

Let f(x) be the probability of success starting from x mana.

If x=0, we have already lost, so f(0)=0.
If x=y, we have already won, so f(y)=1.
If x is between 0 and y, then after this step there is a 1/2 chance that the player will be at x+1 mana and a 1/2 chance he will be at x-1 mana. Therefore, f(x) = (1/2)(f(x+1)) + (1/2)(f(x-1)).

Now suppose f(1) = A. Setting x=1 in the formula and solving for f(2) gives f(2)=2A (since f(0)=0). Similarly, setting x=2 in the formula and using the newly calculated values of f(1) and f(2) gives f(3)=3A, etc., so f(x)=xA. Since f(y)=1 we must have A=1/y, and thus f(x) = x/y. Therefore, the probability of success starting from X mana is X/Y.

Problem 12.2.

The solution is similar to the problem above, except that f(x) = (3/4)f(x+1)) + (1/4)(f(x-1)). If we set f(1)=A, we get f(2) = (1 + 1/3)A, f(3) = (1 + 1/3 + 1/9) A, f(4) = (1 + 1/3 + 1/9 + 1/27) A, and so on. As x approaches infinity, f(x) approaches 3A/2. Since we know f(1,000,000)=1, and by the preceding f(1,000,000) is approximately 3A/2, we have A=2/3. Thus the probability of success is approximately 2/3.

Monday, November 30, 2009

Problem 11 Solution: "You've Been Blocked"

Problem 11a.

There are 27 possible combinations (3^3) of 3 block cards. There are 6 ways of having three different block cards, so the probability of blocking a mixed combo of that type is 6/27. Given a particular range of attack coming in, there is only 1 way of having three block cards all of that type, so the probability is 1/27.

Problem 11b.

Out of the 27 possible combinations of block cards, only 8 of them (2^3) do not have any medium block cards (there's 2 possible choices for each of the 3 cards). Thus there is a 19/27 probability of a successful block.

Problem 11c.

There are 7 possible combinations of block cards that have two or more medium block cards, and 19 that have at least one. Therefore, given that the attack was blocked, there is a 7/19 chance that there is another medium block card in his hand. If there isn't, there is a 1/3 chance that he will draw a medium block card on his next turn. Therefore the chance of him having a medium block card is 7/19 + (1/3 * 12/19) = 11/19.

Sunday, October 11, 2009

Problem 10 Solution: "All Decked Out"

Let G be the average number of coins on the cards in your deck (both treasure cards and +coins action cards) and let C be the average number of +cards on cards in your deck (i.e. 0 for treasure cards and action cards with only +coins, or X for action cards with +X cards).

Let P be the expected value of a single card. On average, a single card gives you G gold plus C new cards, and the expected value of those C new cards is P each. So we have P = G+CP, or (1-C)P = G, or P = G/(1-C). This means that the expected value of a five card draw is 5G/(1-C).

Note that if C is equal to or greater than 1, this means that on average you will be able to keep drawing cards indefinitely, and our assumption that you will never run out of cards in your deck would be inaccurate.

Wednesday, October 7, 2009

Problem 9 Solution: The Killing Fields

Problem 9a.

Suppose that there exists a strategy S that always succeeds with less than N deaths. Suppose that the worst case number of deaths with strategy S is K, and consider an arrangement of kill zones that leads to K deaths. This means that the first K attempts hit a kill zone, and attempt number K+1 gets through. Now move one of the kill zones that didn't get hit (this must exist since K<N) into the path of attempt K+1 (shrinking it as necessary so it doesn't hit paths from other attempts). Then S won't notice anything different until it's too late, because the algorithm didn't hit that kill zone before and won't hit that kill zone this time until attempt K+1, which will hit it. Thus this algorithm will take at least K+1 deaths on this new arrangement, contradicting the assumption that K was the worst case number.

Problem 9b.

Go up in a straight line. If you hit a kill zone, mark a circle of radius 2 around that point - this is the "danger zone" for that kill zone. You know that the kill zone you hit lies entirely within the danger zone, because the center of the kill zone is at most 1 away from where you got hit, and any point in the kill zone is within 1 of the center. Then make another attempt, but this tim maneuver to avoid the danger zone. If you get hit mark another danger zone, and try again avoiding all danger zones marked so far.

This technique will ensure that you never hit the same kill zone more than once. However we still need to show that it will actually get you to the top. Since each danger zone has diameter 4, the sum of the diameters of all the danger zones is equal to 4N which is less than X, so there isn't enough space for the danger zones to completely block the path to the top, so you will be able to get to the top.

Problem 9c.

This is a trick question: there is no limit. If N > X/2, the defender can position his kill zones in a line across the middle, and since the sum of the diameters of the kill zones is 2N which is greater than X, he can completely block the entire path up, so the attacker will never be able to get to the top.

Wednesday, September 30, 2009

Problem 8 Solution: "Focus Fire!"

Let G(i,j) be the best possible expected damage using j models in groups of no more than i each.

First, we know that G(1,j) = j*F(1) for all j, because with groups of no more than 1, you just have j groups of 1.

We will now show how to calculate the values of G(i,*) from the values of G(i-1,*). (the * means all the numbers from 1 to n). Consider a grouping of j models in groups of no more than i, and let x equal the number of groups of size exactly i that it has. Thus the rest of the grouping is a grouping of (j-xi) models in groups of size no more than i-1. Thus the best you can do with this part of the grouping is G(i-1, j-xi). So the best possible expected damage total with x groups of size i is xF(i)+G(i-1, j-xi). If you already know the latter values, then you can simply compute this for all possible values of x to find out what the optimal value of x to choose is.

In this way you can construct the entire table of G(i,j) values where 1 <= i,j <= n by starting with i=1 and working your way upward. With each value of G(i,j) you also keep track of what grouping achieves that value. Then the grouping associated with G(n,n) is the result.

This technique of building up the solution to a complete problem (in this case the overall optimal grouping) from a series of solutions to subproblems (in this case the optimal groupings of smaller sets of models with limits on the maximum number per group) is known as dynamic programming, and is commonly used in algorithms to solve many different problems.

Another bit of trivia: the "groupings of N models" we've been talking about (like grouping a unit of 8 into groups of 3, 3, and 2) are known in combinatorics as partitions of N. The section we just finished in my combinatorics class had a significant part of it devoted to how to count up the number of partitions of N that satisfy different constraints, like no number repeated, maximum number less than 3, numbers can have "colors" associated with them, etc.

Wednesday, September 23, 2009

Problem 7 Solution: By Our Powers Combined

Choose an arbitrary hero H. There are 23 other heroes that H can be paired with, and each pairing must have one of the three fusion types. Therefore, there must exist at least one fusion type such that at least 6 of H's pairings have that type. (In fact you only need 16 other heroes, or 17 including H, for this to be true.) Without loss of generality assume this is true of the targeted fusions.

Now consider any 6 heroes that have a targeted fusion when paired with H. Given these six heroes, form a complete graph with the six heroes as vertices. Color each pairing with a guided fusion red, each pairing with a clearing fusion blue, and the targeted fusions can be colored either red or blue. Then by the special case of Ramsey's Theorem that was previously mentioned, there must exist a group of three whose pairings all have the same color. Without loss of generality assume that this color is red. Now those three have only targeted and guided fusions between them. If you form a team consisting of those three and H, they still only have targeted and guided fusions (because adding H just adds targeted fusions) so they have no clearing fusions available. QED.

Note that the Ramsey's Theorem article also includes a "multicolour example" with three colors that, coincidentally, also requires 17 vertices. However this is not the same as our problem. In that problem they are looking for groups of three that have only one edge color, in this problem we are looking for groups of four that have two edge covers. In fact since R(4,4)=18 (as explained in the article) with 18 or more heroes it would be impossible to make sure every team of 4 had one of each fusion type even if there were only two fusion types.

Sunday, September 13, 2009

Problem 6 Answer: "Taking Inventory"


Problem 6.1.

To reduce BIGP to IGP, take each object, as well as the entire grid, and increase its length and width by 1 each. For example, if the BIGP problem had an 8x10 grid, and y one 4x6 object, three 3x3 objects, and five 2x1 objects, the corresponding IGP problem has a 9x11 grid, with one 5x7 object, three 4x4 objects, and five 3x2 objects. If there is a solution to the BIGP problem, then the corresponding solution to the IGP problem can be gotten by extending each object one square right and down - this is always possible because of the buffer. To get from the solution to the IGP problem to the solution to the BIGP problem just go the other way. The image gives an example.

To reduce IGP to BIGP, just reverse the process - decrease each object's length and width by 1
each, and also decrease the grid's length and width by 1 each. However this runs into a problem because it's possible that some of the objects have a length or width of 1, and thus can't be decreased farther. If this is the case then first double the dimensions of all the objects in the IGP problem - this won't change the solution.

Problem 6.2.

Given an instance of the bin-packing problem with N bins of capacity V and a set of objects of size S1, S2, S3, etc., create an instance of IGP with an NxV grid and objects of size 1xS1, 1xS2, 1xS3, etc. Then a solution to the IGP instance can be converted into a solution to the bin-packing problem by putting each object into the bin corresponding to the row that the object was put in in the IGP solution, and of course if there is a solution to the bin packing problem it can be converted into a solution to the IGP instance by reversing the process. So the IGP instance has a solution if and only if the bin packing instance has a solution, so the reduction works.

Thursday, January 22, 2009

Problem 5 Answer: "Mathematically Challenged"

(a) The best strategy is to have everyone except the person with the +8 skill modifier use the aid another action, and have only the person with the +8 skill modifier actually make rolls for success or failure.

(b) No matter how high the aid another DC was, the above strategy would still be optimal. Even if the aid another DC was so high it was impossible to succeed at, aid another is still useful because it effectively removes the character using it from the rotation. So in this case, having everyone but the +8 player using aid another means that all the meaningful skill checks are made at +8, maximizing the chance of winning.