Showing posts with label induction. Show all posts
Showing posts with label induction. Show all posts
Wednesday, March 2, 2022
Hyper-triangular numbers
Triangular number $T_n$ is defined as $T_n = 1 + 2 + \dots + n$.
Tetrahedral number $R_n$ is defined as $R_n = T_1 + T_2 + \dots + T_n$.
Let $T^k_n$ denote the $k$-th dimensional triangular numbers, with $T^1_n = 1+1+\dots+1 = n$, $T^2_n = T_n$, and $T^3_n = R_n$. Specifically, the higher dimensional triangular numbers are defined as:
$$ T^{k+1}_n = T^k_1 + T^k_2 + \dots + T^k_n$$
Prove that:
$$T^k_n.T^m_1 + T^k_{n-1}.T^m_2 + \dots + T^k_1.T^m_n = T^{k+m+1}_{n+1}$$
Monday, March 18, 2019
Triangular equations
A triangular series of equations is a system of $k$ equations where the $k$-th row consists of $k+1$ terms on the LHS and $k$ terms on the RHS. For example:
$$a + b = c$$
$$d + e + f = g + h$$
$$i + j + k + l + m = n + o + p$$
$$...$$
Given the numbers $1, 2, \dots, n^2$ and one number with the same parity as $n$ is removed, prove that the rest of the numbers can be arranged into a triangular series of equations.
For example, out of $1,2,\dots,9$, 3 is removed, so the rest can be written as:
$$ 1+4 = 5$$
$$2 + 6 + 8 = 7 + 9$$
Another example, out of $1,2,\dots, 16$, 10 is removed, so the rest can be written as:
$$1+3 = 4$$
$$2 + 5 + 8 = 6 + 9$$
$$7 + 11 + 12 + 14 = 13 + 15 + 16 $$
Solution (In Progress)
Suppose we color all the numbers with the same parity as $n$ with red, and color all the numbers with the opposite parity with black. Also, call the number that was removed, the missing number, $x$. A number is called "good" if, when missing, the rest of the numbers can be written as triangular system.
Note the triangular system below:
$$1+2 = 3$$
$$4+5+6 = 7+8$$
$$9+10+11+12 = 13+14+15$$
$$...$$
$$k^2 + \dots + (k^2+k) = (k^2+k+1) + \dots + (k^2+2k)$$
$$...$$
$$(n-1)^2 + \dots + ((n-1)^2+n-1) = ((n-1)^2+(n-1)+1) + \dots + (n^2-1)$$
We call this system A. This system is missing $n^2$, and the system is triangular and correct. (The correctness of said system can be verified by simple arithmetic series on the $k$-th row).
So we know that $n^2$ is good. Furthermore, note that each row has the same number of odd numbers (that is, $k$-th row has $k$ odd numbers if $k$ is odd and $k-1$ odd numbers if $k$ is even). So if we increase each odd number by two, we'll still get a correct triangular system:
$$3+2 = 5$$
$$4+7+6 = 9+8$$
$$11+10+13+12 = 15+14+17$$
$$...$$
So if $n$ is odd, 1 is good. Call this system B.
Similarly, the $k$-th row has $k$ even numbers in the LHS and $k-1$ even numbers in the RHS. We can increase the even numbers by two, but then the equation will be incorrect. Call the "weight" of an equation to be its RHS - LHS. Obviously, an equation is correct only if it has weight zero. If we increase all the even numbers by two, then the weight of the new equation is -2, for example:
$$6+5+8 > 7+10,w=-2$$
But note that now $(k^2+k+2)$ is in the LHS while $k^2+k+1$ is still in the RHS. In other words, the largest number in the LHS is exactly one more than the smallest number in the RHS, so if we switch those two, we restore the weight back to zero:
$$6+5+7 = 8+10$$
So we can form a new system this way:
$$1+3=4$$
$$6+5+7 = 8+10$$
$$9+12+11+13 = 14+16+15$$
$$...$$
Next, note that out of the $n$ rows in the equation, we can take the first $k$ rows from system A, and the $n-k$ last rows from system B or C. For example:
$$1+2 = 3$$
$$4+5+6 = 7+8$$
$$11+10+13+12 = 15+14+17$$
$$...$$
Now we are ready to prove the main assertion by induction. We will show the base cases later. For now, suppose it holds for $n=2,3$. Then, if $x \leq (n-2)^2$, there is a way to arrange $\{1, 2, \dots, (n-2)^2\} \ \{x\}$ in triangular form by induction hypothesis, and the last two rows can be taken from the last two rows of system B (if $n$ is even) or system C (if $n$ is odd). So then we consider cases where the missing number is $x > (n-2)^2$. In system A above, it would be in the last two rows. We will divide into cases depending on the position of $x$ in system A. Note that the missing number is always red.
Suppose $x$ is red on the last row RHS (meaning the missing number is in the interval $x \ in [(n-1)^2+(n-1)+1, n^2-2]$). Take out that number and replace it with $n^2$. Then now the last row has weight a positive even number in the interval $[2, n-1]$. We can switch a number $k$ from LHS and $l$ from the RHS, and the weight would decrease by $2(l-k)$. But the difference of the numbers in RHS and LHS ranges from 1 to $2n-2 > n-2$, and each side has consecutive numbers. So we know there are numbers that we can pick to switch so that the weight is reduced back to zero.
Suppose the missing number is red on the last row LHS, meaning the missing number is in the interval $x \in [(n-1)^2+1, (n-1)^2+(n-1)]$. Take out that number and replace it with $n^2$. Then the last row has weight a negative even number in the interval $[-2n+2, -n]$. Now, there exists a number in RHS $y$ such that $y-n^2$ is exactly half the weight of the last row, because the numbers in RHS is in the range $[(n-1)^2+(n-1)+1,n^2-1]$ so those numbers subtracted by $n^2$ is in the range $[-n+1, -1]$ which encompasses $\frac{1}{2} [-2n+2, -n]$. If we switch this number $y$ and $n^2$, the weight of the last row is restored.
Suppose the missing number is red on the second-to-last (STL) row LHS, meaning the missing number is in the interval $x \in [(n-2)^2, (n-2)^2+(n-2)]$. Take out that number and replace it with $(n-1)^2+1$, and then in the last row, put $n^2$ to where $(n-1)^2+1$ used to be. The STL row now has weight negative even number in the interval $[-2n+2,-n]$, whereas last row has some other even number weight. The last row could be fixed with the procedure described above (as if $(n-1)^2+1$ was the missing number). However the STL row can be fixed by switching $(n-1)^2+1$ with an appropriate number in the STL RHS, because the numbers in STL RHS ranges from $[n^2-3n+3,n^2-2n]$ so the difference ranges from $[-n+1, -2]$ which encompasses $\frac{1}{2}[-2n+2,-n]$
Suppose the missing number is red on the STL row RHS. Same as before, take out that number, replace it with $(n-1)^2+1$, and then in the last row, put $n^2$ to where it used to be. Same as above, the last row can be fixed using the previous strategy, whereas the STL row can be fixed by switching two numbers in the STL (similar to if the missing number is from RHS last row).
Now all that remains is to prove the base cases. For $n=2$, we have either $1+3=4$ or $1+2=3$. For $n=3$, the missing numbers could be $x=1,3,5,7,9$, but $x=9$ is already covered by system A above, $x=1$ covered by system B, and $x=3$ is shown in the example. For $x=5$:
$$1+2=3$$
$$4+7+6 = 9+8$$
For $x=7$:
$$1+3=4$$
$$2+5+8 = 6+9$$
(Really we're just applying the algorithm described above but we're including here for the sake of proof completeness).
Saturday, May 5, 2018
Moving coins across the board
On a $1 \times 2018$ chess-board, the $n (n < 2018)$ left-most squares contain 1 coin each. Alice and Bob are playing a game, where on each turn the player may choose a coin and move it to the right one or two units. The only condition is that each square may only contain one coin at a time (no "stacking"), except the last square (right-most square). Alice goes first. The player who cannot make a legal move loses. Determine all $n$ such that Alice has a winning strategy.
Solution
Label each square by its distance from the right-most square. So the right-most square is called square zero, and the left-most square is called square 2017. Suppose $(a_1, a_2, \dots, a_k)$ denotes the condition that there is a coin on each of the cells $a_1, \dots, a_k$ and the rest of the coins are in the square zero. WLOG, we may assume $a_1 < a_2 < \dots < a_k$.
Claim:
We claim that $(a_1, \dots, a_k)$ is a losing position if and only if $a_1 + \dots + a_k$ is divisible by 3.
First note that the game ends only when there's no more legal move left, and that's when all the coins are on square zero. So as long as the sum of the coin numbers are greater than zero, there is always a legal move available. At the very least, the coin with the lowest number can be moved to the right 1 or 2 steps (possibly reaching zero in the process).
Lemma:
If the sum of the numbers are not divisible by 3, there is always a legal move to make it divisible by 3 within one turn.
Note that our claim is a corollary of the lemma. If the sum of the numbers is divisible by 3, then no matter what move you do, you can only reduce it by 1 or 2. Based on the lemma, the opponent can always counter it by bringing down to the next multiple of 3. Therefore, your opponent will never face the situation without any legal move. Conversely, if it's not divisible by 3, you can always bring it to a multiple of 3 within one turn so that your opponent is facing a losing position next. And your winning strategy is always to keep the sum of the numbers divisible by 3.
Proof of lemma:
If the the sum of the numbers is $3m+1$, then you only need to move the lowest-numbered coin down by 1. This is always possible because it is at least 1. If the sum of the numbers is $3m+2$, then you need to move ANY coin down by 2. Suppose that this is not possible, either due to prospect of collision or running against the end of the board. That means the following:
1. There are no two consecutive empty cells. If there are two or more consecutive empty cells, then the coin to the left of that block can be moved down by two. This means that $a_i - a_{i-1} = 1,2$ for each $i$.
2. There is nothing on cell 2, because otherwise we can always move it to cell 0 directly.
3. There is no "jumping over" possible. Meaning, if cell $x$ is empty but $x+1,x+2$ are both occupied, we can take $x+2$ and move it to $x$. So this configuration is not allowed: EMPTY, OCCUPIED, OCCUPIED.
This means cell 1 has a coin on it. $a_1 = 1$. Since 2 is empty, then 3 must have a coin on it ($a_2 = 3$). If 4 has a coin on it, then it violates condition 3 above, so 4 must be empty. That means 5 must be occupied (by condition 1). We can continue this pattern indefinitely, to arrive at the conclusion that current condition must be: $(1,3,5, \dots, 2k-1)$. The sum of the numbers is therefore $1 + 3 + \dots + 2k-1 = k^2$, which cannot be $3m+2$. Contradiction. Hence it's always possible to choose a coin to move down by 2. This completes our proof of the lemma.
Now, the initial condition is $(2018-(n-1), 2018-(n-2), \dots, 2018)$, so that the sum of the numbers is: $n(4037-n)/2$. For this to be divisible by 3, either $n$ is divisible by 3, or $n \equiv 2 \mod 3$. These are the losing positions. So in order for Alice to have winning strategy, $n \equiv 1 \mod 3$.
Labels:
Combinatorics,
game,
induction,
invariant,
Sprague-Grundy,
turn,
winning-strategy
Tuesday, April 3, 2018
Uniquely Reachable Numbers
Let $n > 1$ be an integer. Given set $A_n = \{ 1, 1, \dots, 1, 2, 2, \dots, 2, \dots, n-2, n-2, n-1, n \}$
where there are:
$2^{n-1}$ number $1$
$2^{n-2}$ number $2$
$\dots$
$2^2$ number $n-2$
$2$ number $n-1$
$1$ number $n$
$1$ number $n+1$
(As you can see, there are a total of $2^n$ numbers in $A_n$).
A positive integer is called "reachable" if it can be expressed as a sum of $2^{n-1}$ numbers in $A_n$. A reachable number is called "uniquely reachable" if that sum is unique (not counting permutations of the summands).
For example, for $n=3$, we have $A_3 = \{1,1,1,1,2,2,3,4\}$. The number 10 is uniquely reachable because it can be expressed as $10 = 1+2+3+4$ and this representation is unique (we consider $1+2+3+4$ and $3+4+2+1$ to be the same way). However, the number $6$ is not unique because $6 = 1+1+2+2 = 1+1+1+3$.
Find all the uniquely reachable numbers.
Solution
Answer: the only uniquely reachable numbers are $2^{n-1}, 2^{n-1}+1, 3.2^{n-1}-2,3.2^{n-1}-1$.
Proof:
We prove by induction. Now first note a few things:
The sum of all numbers in $A_n$ is $2^{n+1}-1$. So the number $k$ is reachable iff the number $2^{n+1}-1-k$ is reachable. Similarly, $k$ is uniquely reachable iff the number $2^{n+1}-1-k$ is uniquely reachable. We prove this by simply taking the complement of the numbers chosen to represent $k$. There are exactly half of the numbers in the set, so the sum of the numbers that are not chosen to represent $k$ will be $2^{n+1}-1-k$.
Also, the range of reachable numbers is from $2^{n-1}$ to $3.2^{n-1}-1$ (by taking the $2^{n-1}$ smallest numbers, that is all ones, all the way to the largest numbers, that is everything but ones). So any number outside of this interval is clearly not reachable by any choice of $2^{n-1}$ numbers in $A_n$.
We shall prove the following statements in tandem:
1. All numbers in the interval $[2^{n-1}, 3.2^{n-1}-1]$ are reachable
2. The uniquely reachable numbers are $2^{n-1}, 2^{n-1}+1, 3.2^{n-1}-2,3.2^{n-1}-1$.
These statements are easy to verify for $n=2$. Now suppose they all hold for $n-1$.
Claim 1: If $k$ is (uniquely) reachable in $A_{n-1}$ (it can be expressed as sums of $2^{n-2}$ numbers in $A_{n-1}$) then $k+2^{n-2}$ is (uniquely) reachable in $A_n$.
Proof: Take $k$ and its representation of $2^{n-2}$ summands, and add $2^{n-2}$ ones to it. This new representation is valid in $A_n$ because there are at most $2^{n-2}$ ones in $A_{n-1}$, and by adding $2^{n-2}$ more ones, we are using at most $2^{n-1}$ ones. The other numbers that are represented in $A_{n-1}$ are unchanged and still available to use in $A_n$. Each distinct representation of $k$ will yield a new representation of $k + 2^{n-2}$, so the uniqueness of reachability also transfers to the new representation.
Claim 2: If $k$ is (uniquely) reachable in $A_{n-1}$ then $k + 3.2^{n-2}$ is (uniquely) reachable in $A_n$.
Proof: If $k$ is (uniquely) reachable in $A_{n-1}$ then $2^n-1-k$ is (uniquely) reachable in $A_{n-1}$, then by claim 1, $2^n-1-k+2^{n-2}$ is (uniquely) reachable in $A_n$, therefore $2^{n+1}-1-(2^n-1-k+2^{n-2}) = k + 3.2^{n-2}$ is also (uniquely) reachable in $A_n$.
From the two claims above, because all numbers in the interval $[2^{n-2}, 3.2^{n-2}-1]$ are reachable in $A_n$, now we apply claim 1 to this interval. We have the interval $[2^{n-1}, 2^n-1]$ reachable in $A_n$. Similarly, we apply claim 2 to this interval, we have $[2^n, 3.2^{n-1}-1]$ reachable in $A_n$. By combining these two intervals, we have $[2^{n-1}, 3.2^{n-1}-1]$ reachable in $A_n$. Thus we have proven statement 1 of the induction hypothesis.
Now we prove uniqueness. By induction hypothesis, the numbers in the interval $[2^{n-2}+2, 3.2^{n-2}-3]$ are reachable but not uniquely in $A_{n-1}$. By claim 1, we can the interval $[2^{n-1}+2, 2^{n}-3]$ is reachable but not uniquely. Likewise, we can claim 2 to establish that the interval $[2^n+2, 3.2^{n-1}-3]$ is reachable but not uniquely. Then now we know that all numbers in the interval $[2^{n-1}+1, 3.2^{n-1}-3]$ are reachable but not uniquely, except of the following four numbers: $2^n-2, 2^n-1, 2^n, 2^n+1$. They are reachable but not yet proven as uniquely reachable.
Claim 3: If $k$ is (uniquely) reachable in $A_{n-1}$ then $k + 2^{n-1}$ is (uniquely) reachable in $A_n$.
Proof: First note that $A_n$ can be formed by adding one to each element of $A_{n-1}$ and then adding $2^{n-1}$ to it. Now, take any representation of $k$ in $A_{n-1}$. Add 1 to each summand, and then add $2^{n-2}$ ones to it. Now we have $2^{n-1}$ summands, and only $2^{n-2}$ are ones. The rest (the higher summands) are valid in $A_n$ because they were 1 more than the summands that were valid in $A_{n-1}$. The new sum is $k + 2^{n-2} + 2^{n-2} = k+2^{n-2}$. Distinct representations in $A_{n-1}$ would also result in distinct representations in $A_n$.
Because $n \geq 4$, we have $2^{n-2}+2 \geq 2^{n-1}-2$ and $2^{n-1} \leq 3.2^{n-1}-3$, so by induction hypothesis, $2^{n-1}-2$ and $2^{n-1}$ are non-uniquely reachable in $A_{n-1}$, then $2^n-2$ and $2^n$ are non-uniquely reachable in $A_n$. Then, their complements $2^n-1$ and $2^n+1$ are also non-uniquely reachable. This completes our proof of statement 2
Wednesday, December 13, 2017
Product of cosines
For $n$ natural number, and $a = \frac{2\pi}{2n+1}$ find the value of
$$\cos a . \cos 2a . \cos 3a . \dots . \cos na$$
Solution
We first prove the following claim: for any $n$ positive odd number,
$$\sin (nx) = \sin x P_n (\cos x)$$
$$\cos (nx) = \cos x Q_n (\cos x)$$
where $P_n(t)$ and $Q_n(t)$ are polynomials in the form of $2^{n-1} t^{n-1} + ...$ (In other words, they have degree $n-1$ and the leading coefficient $2^{n-1}$
Proof by induction, evident for $n=1$ and $n=3$. Inductive step:
$$\sin (n+2)x = \sin nx \cos 2x + \cos nx \sin 2x = \sin x P_n (\cos x) (2 \cos^2 x - 1) + \cos x Q_n (\cos x) .2\sin x \cos x$$
$$ = \sin x ( P_n (\cos x) (2 \cos^2 x - 1) + 2\cos^2 x Q_n (\cos x) ) = \sin x P_{n+2} (\cos x)$$
where $P_{n+2}$ has degree $n+2$ and the leading coefficient $2. 2^{n-1} + 2.2^{n-1} = 2^{n+1}$
Likewise:
$$\cos (n+2) x = \cos nx \cos 2x - \sin nx \sin 2x = \cos x Q_n(\cos x)(2 \cos^2 x - 1) - \sin x P_n (\cos x) . 2 \sin x \cos x$$
$$ = \cos x ( Q_n(\cos x)(2 \cos^2 x - 1) - 2 P_n (\cos x) (1 - \cos^2 x)) = \cos x Q_{n+2} (\cos x)$$
like before, the polynomial $Q_{n+2}$ has degree $n+2$ and leading coefficient $2^{n+1}$
So now, observe that $x = 0,a,2a, \dots, 2na$ are all solutions of the equation
$$\cos (2n+1)x = 1 = \cos x Q_{2n+1}(\cos x)$$
Therefore $t = \cos 0, \cos a, \dots, \cos 2na$ are all roots of the polynomial
$$ S(t) = tQ_{2n+1}(t) - 1$$
Because $S(t)$ has degree $2n+1$, then $\cos 0, \dots \cos 2na$ are ALL of the roots, and the product of all those roots is $\frac{1}{2^{2n}}$ (because $S(t)$ has leading coefficient $2^{2n}$
Now, $\cos a = \cos 2n a, \cos 2a = \cos (n-1) a$ and so on.
So:
$$\cos 0 . \cos a .\dots. \cos 2na = 1 . (\cos a. \dots . \cos na)^2 = \frac{1}{2^{2n}}$$
So:
$$\cos a . \dots . \cos na = \frac{1}{2^n}$$
Labels:
Algebra,
cosine,
fundamental theorem of algebra,
induction,
polynomial,
sine,
trigonometry
Tuesday, October 10, 2017
symmetric 2 variable function
Suppose $S = \{1,2,\dots,n\}$ and $f: S \times S \to R$ satisfies the following:
$$f(i,j) + f(j,i) = 0 \forall i,j \in S$$
Now for any two number $i,j$, we say that $i$ is superior to $j$ if there exists a $k$ (not necessarily distinct from $i,j$) such that $f(i,k) + f(k,j) \geq 0$.
Show that there exists a number $x \in S$ such that $x$ is superior to all elements of $S$.
Labels:
Algebra,
Combinatorics,
function,
graph,
graph theory,
induction,
maximal principle,
strong induction
Wednesday, September 20, 2017
ODE discrete version
If $f$ is a function that is defined over natural numbers ($f:N \to R$), let $f^*$ denote the function $f^*(n) = f(n) - f(n-1)$.
Find all functions such that
$$n(f^*)^*(n) + (n-1)f^*(n) = f(n)$$
for all $n > 2$
Solution
We can check that $f(n) = A(n-1) + B/2^n$ for any constant $A,B$ satisfies the given equation. Now we show that there's nothing else.
Define $g = f^*+f$. The equation is identical to:
$$n(f^*+f)^*(n) =(f^*+f)(n)$$
$$ n(g(n) - g(n-1)) = ng^*(n) = g(n)$$
$$\frac{g(n)}{n} = \frac{g(n-1)}{n-1}$$
for all $n>2$, therefore $g(n)/n$ must be a constant. Remember that $g(1)$ is not defined because $f$ is only defined for $n \geq 1$ thus $g$ is only defined for $n \geq 2$. Furthermore, the value $g(2)$ depends on $f(1)$ and $f(2)$.
Case 1: $g(2) = 0$
In this case then $g(n) = 0 \forall n$.
$$(f^*+f)(n) = 0$$
$$f(n) = f(n-1)/2$$
so we easily get $f(n) = k/2^n$ for some constant $k$.
Case 1: $g(2) \neq 0$
Note that if $f$ is a solution to the problem then $kf$ is also a solution to the problem, for all $k$ real numbers. If we replace $f$ by $kf$, then $g$ is also replaced by $kg$. So WLOG, we may assume that $g(2) = 2$
Because $g(n) / n$ is a constant then
$$g(n) / n = g(2) / 2 = 1$$ so $g(n) = n \forall n >2$
$$f(n) = \frac{f(n-1) + n}{2}$$
for all $n > 2$.
Because $g(2) = 2 = 2f(2) - f(1)$ then $f(2) = 1+ f(1)/2$
Now notice this pattern:
$$f(3) = \frac{f(2) + 3}{2} = 2 + f(1)/4$$
$$f(4) = \frac{f(3) + 4}{2} = 3 + f(1)/8$$
Easy to prove by induction that $f(n) = n-1 + f(1)2^{1-n}$.
From the two cases above, it's clear that any solution of the equation must be in the form of $f(n) = A(n-1) + B/2^n$ for any constant $A,B$
Wednesday, April 8, 2015
Circles on a sphere
Given a sphere of radius $R$, we draw 2015 circles with radius $R$ on it, such that there are no three circles that all meet in one point.
It's easy to see that there will be $2^{2015}$ regions created on the sphere surface. Prove that we can color each region with black or white so that no two adjacent regions are colored the same and the total area painted black is the same as the total area painted white.
Wednesday, November 5, 2014
Prisoners With Hats Again
This is a generalization of the latest logic problem in MIT's Technology Review, November/December 2014
There are $n$ prisoners, $a_1, a_2, \dots, a_n$ where each prisoner is a perfect logician. Also, $a_n$ is blind but the other ones can see.
Initially they're all blindfolded. There are $n$ white hats and $n-1$ black hats, and out of those $2n-1$ hats, $n$ hats are randomly selected, and the rest hidden. Each prisoner is then given one of those $n$ hats to wear. At the same time, all the blindfolds are taken off.
Then the prisoners said the following things, in this order:
$a_1$ said: "I don't know my hat color."
$a_2$ said: "I don't know my hat color."
$a_3$ said: "I don't know my hat color."
...
$a_{n-1}$ said: "I don't know my hat color."
$a_n$ said: "I know my hat color."
What is $a_n$'s hat color?
$a_1$ said: "I don't know my hat color."
$a_2$ said: "I don't know my hat color."
$a_3$ said: "I don't know my hat color."
...
$a_{n-1}$ said: "I don't know my hat color."
$a_n$ said: "I know my hat color."
What is $a_n$'s hat color?
Solution
If $a_1$ saw all black hats, then he would know that his hat is white, because there are at most $n-1$ black hats in the room. Because he doesn't know his hat color, then at least one of $a_2,\dots,a_n$ is white. Likewise, if $a_2$ saw all black hats among $a_3, \dots, a_n$, given the information that at least one of $a_2, \dots, a_n$ is white, he would know that his hat is white. Because $a_2$ doesn't know his hat color, then at least one of $a_3, \dots, a_n$ is white. We can continue this line of reasoning via induction. The hypothesis is that at least one of $a_k, \dots, a_n$ is white. If $a_{n-1}$ saw that $a_n$ has black, he would know that he has white. Because $a_{n-1}$ doesn't know his hat color, that means $a_n$ has white.Sunday, February 2, 2014
Random walk sequences
Let $n$ be a natural number. Suppose $a_1, a_2, \dots$ are sequences of +1s and -1s. Also define $s_k = a_1 + a_2 + \dots + a_k$, and define $s_0 = 0$. Such sequence is called "complete" if for each $i \in {0, \dots, n-1}$ there exists $k$ such that $s_k \equiv i \mod n$.
What is the largest number $S$ such that the following statement is true: For every complete sequence, there exists $j,k \geq 0$ such that $|s_j - s_k| = S$.
What is the largest number $S$ such that the following statement is true: For every complete sequence, there exists $j,k \geq 0$ such that $|s_j - s_k| = S$.
Answer:
$n-1$ We can construct $a_i$ as follows: $n-1$ +1s, followed by $n-1$ -1s, and followed by $n-1$ +1s again, alternatingly. It's easy to see that this sequence is complete. Moreover, the sum of any contiguous block ranges from $-(n-1)$ to $(n-1)$. So clearly for this particular sequence, $S \leq n-1$ fulfills the statement, and $S > n-1$ is not satisfied by this sequence. Now we have to prove that for $S=n-1$ and any given complete sequence, the problem statement is fulfilled.First Solution
The sequence is infinite, but suppose we can truncate it to the smallest sequence so that it's still complete. In other words, suppose the sequence $a_1, \dots, a_N$ is complete but $a_1, \dots, a_{N-1}$ is not. Let $s_N = x$. Because $N$ is the smallest index such that it's still complete, that means $s_i \equiv x \mod n$ does not happen before $N$. Consider $a_N$. It can be either +1 or -1. Suppose it's +1 (the case of -1 is similar). So that means $s_{N-1} = x-1$. Let $p$ be the an index such that $s_p \equiv x+1 \mod n$. We know $p$ exists because the sequence is still complete. Also that $p < N-1$. That means $s_{N-1} - s_p \equiv (x-1) - (x+1) \equiv -2 \mod n$. But from $i = p$ to $i = N-1$ we can't have $s_i = x$, so that means $s_{N-1} - s_p = tn - 2$ for some $ t > 0$. This means that $s_N - s_p = tn-1$. But if $t > 1$, then we must have some $r$ such that $p < r < N$ and $s_N - s_r = n, s_r - s_p = (t-1)n-1$. But this yields a contradiction, because then $s_r \equiv s_N \equiv x \mod n$ and thus $a_1, \dot, a_r$ is complete, violating our condition that $N$ is the smallest complete sequence. Thus we must have that $t=1$ and consequently $s_N - s_p = n-1$Second Solution
Suppose that there is no contiguous block whose sum is $\pm(n-1)$. Each contiguous block must have sum of at most $(n-2)$ and at least $-(n-2)$. Now, if there is $k$ such that $s_k = n-1$ then we are done, because it would imply a contiguous block from $0$ to $k$ with sum $n-1$. So let $x$ be the maximum value of $s_i$, where $x \leq n-2$. Likewise, let $y$ be the minimum value of $s_i$ where $y \geq -(n-2)$. Because the sequence is complete, then we must have that $x-y \geq n-1$, otherwise some values won't be "reached" by $s_i$ at all. But this means that there is a contiguous block from the maximum to the minimum or vice versa, and their sum is $\pm(n-1)$
Labels:
Algebra,
Combinatorics,
cumulative sum,
induction,
random walk,
sequence
Tuesday, February 21, 2012
Maximal non-intersecting boat tours
In a country, there are $n$ islands, and each island has exactly one port. A travel agency is planning a series of boat tours where it would employ a number of boats that start and end on these ports. They must obey these rules:
1. Each tour starts and ends at the same port and does not stop at any other port. That is, each tour is a loop that passes through exactly one port.
2. No two tours may intersect each other, except at ports.
3. For two distinct tours A and B, either A must circle an island that B doesn't, or B circles an island that A doesn't. By "circling" an island we mean: the region created by the tour contains the island.
Assuming that all islands have non-zero area and all boats are treated as points, what is the largest number of tours that can be run at the same time?
Solution
Answer: $2n$
First we will show an arrangement of $2n$ tours that satisfy the given constraints, and then we shall show that it is the largest attainable number.
For each island, have a tour that starts at that island and circle it closely to the shore so that we don't greatly alter the shape of the island. Altogether, there are $n$ of such tours.
Then, label the island $I_1, \dots, I_n$. For each $i = 2, \dots, n$, have a tour that starts at $I_1$, circles $I_1, \dots, I_i$ and comes back to $I_1$. There are $n-1$ such tour. Finally we can have a tour that doesn't circle any island. In total, there are $2n$ tours.
The proof for maximality is similar to our construction. There can be at most one tour that doesn't circle any island, and there can be at most $n$ tours that circle exactly one island. Now we show that there are at most $n-1$ tours that circle multiple islands. Let's call a tour that circles multiple islands a "complex" tour.
Suppose $T_1$ and $T_2$ are both complex tours and both circle an island in common $I_1$. Furthermore, WLOG, we can assume that $T_1$ circle an island $I_2$ that $T_2$ doesn't. We assert that $T_2$ must be inside $T_1$. Otherwise, the possibilities are either $T_1$ is inside $T_2$, which is impossible since $T_2$ doesn't contain $I_2$, or that they are disjointed, which is impossible because they both contain $I_1$, or that they intersect. There must be at least two points of intersection, but they can only intersect in ports and they each can stop in oneport only, also impossible. Thus, we have just proved the following statement:
Given two complex tours, either they are disjoint or one is inside the other.
From here, it's matter of induction to show that there can be at most $n-1$ complex tours given $n$ islands. Take the smallest complex tour $T$ that does not contain another complex tour. $T$ circles at least two islands, and any other complex tour either contains $T$ or is disjoint from $T$. So as far as other complex tours are concerned, we can regard $T$ as an island on its own, thereby reducing the number islands by at least 1. Since there are now at most $n-1$ "islands", then there are at most $n-2$ complex tours. Altogether with $T$, we have at most $n-1$ tours.
1. Each tour starts and ends at the same port and does not stop at any other port. That is, each tour is a loop that passes through exactly one port.
2. No two tours may intersect each other, except at ports.
3. For two distinct tours A and B, either A must circle an island that B doesn't, or B circles an island that A doesn't. By "circling" an island we mean: the region created by the tour contains the island.
Assuming that all islands have non-zero area and all boats are treated as points, what is the largest number of tours that can be run at the same time?
Solution
Answer: $2n$
First we will show an arrangement of $2n$ tours that satisfy the given constraints, and then we shall show that it is the largest attainable number.
For each island, have a tour that starts at that island and circle it closely to the shore so that we don't greatly alter the shape of the island. Altogether, there are $n$ of such tours.
Then, label the island $I_1, \dots, I_n$. For each $i = 2, \dots, n$, have a tour that starts at $I_1$, circles $I_1, \dots, I_i$ and comes back to $I_1$. There are $n-1$ such tour. Finally we can have a tour that doesn't circle any island. In total, there are $2n$ tours.
The proof for maximality is similar to our construction. There can be at most one tour that doesn't circle any island, and there can be at most $n$ tours that circle exactly one island. Now we show that there are at most $n-1$ tours that circle multiple islands. Let's call a tour that circles multiple islands a "complex" tour.
Suppose $T_1$ and $T_2$ are both complex tours and both circle an island in common $I_1$. Furthermore, WLOG, we can assume that $T_1$ circle an island $I_2$ that $T_2$ doesn't. We assert that $T_2$ must be inside $T_1$. Otherwise, the possibilities are either $T_1$ is inside $T_2$, which is impossible since $T_2$ doesn't contain $I_2$, or that they are disjointed, which is impossible because they both contain $I_1$, or that they intersect. There must be at least two points of intersection, but they can only intersect in ports and they each can stop in oneport only, also impossible. Thus, we have just proved the following statement:
Given two complex tours, either they are disjoint or one is inside the other.
From here, it's matter of induction to show that there can be at most $n-1$ complex tours given $n$ islands. Take the smallest complex tour $T$ that does not contain another complex tour. $T$ circles at least two islands, and any other complex tour either contains $T$ or is disjoint from $T$. So as far as other complex tours are concerned, we can regard $T$ as an island on its own, thereby reducing the number islands by at least 1. Since there are now at most $n-1$ "islands", then there are at most $n-2$ complex tours. Altogether with $T$, we have at most $n-1$ tours.
Labels:
boat,
Combinatorics,
differential geometry,
Geometry,
induction,
island,
topology
Thursday, July 21, 2011
Sequence modulo 2011
A sequence of integers $a_1, \dots, a_{2010}$ satisfy the following properties:
$a_1 - 1$ is divisible by 2011
$a_k a_{k-1} - k$ is divisible by 2011 for $k = 2, 3, \dots, 2010$
Show that $a_{2010} + 1$ is divisible by 2011.
Solution
First we prove the following assertion:
For $k$ odd, then $a_k.2.4.6. \cdots.(k-1) - 1.3.5.\cdots.k$ is divisible by 2011.
For $k$ even, then $a_k.1.3.5. \cdots .(k-1) - 2.4.6.\cdots.k$ is divisible by 2011.
Proof by induction. It can easily be seen for $k=1$ it's true. For $k=2$, we have $2011 | a_2a_1 - 2 = a_2(a_1-1) + (a_2-2)$ So $2011 | a_2 - 2$
Suppose it's true for $k-1$ odd, then for $k$ even:
$2011 | a_k a_{k-1} - k$ which means
$$2011 | 2.4.\cdots.(k-2) (a_k a_{k-1} - k) = 2.4.\cdots.(k-2)a_k a_{k-1} - 2.4.\cdots.(k-2).k$$
$$2011 | a_k (2.\cdots.(k-2)a_{k-1} - 1.3.\cdots.(k-1)) + (a_k.1.3.\cdots.(k-1) - 2.\cdots.(k-2).k)$$
And since 2011 divides the first term by induction hypothesis, then it also divides the second term, which completes the induction step. The proof for $k-1$ even and $k$ odd is similar.
Now, that means for $k=2010$, let $X = a_{2010}$ we have:
$$2011 | X.1.3. \cdots .2009 - 2.4.\cdots.2010$$
We now prove the following assertion for $i = 1,2,\dots,1005$
$$2011 | X.1.3. \cdots. (2011-2i) + (-1)^i (2i) (2i+2)\cdots.2010$$
For $i = 1$ it is true by definition. Now suppose it's true for $i-1$, then for $i > 1$:
$$2011 | X.1.3. \cdots. (2011 - 2i).(2011-2i+2) +(-1)^{i-1} (2i-2) (2i)\cdots.2010$$
if $2011 | a(2011+b) + c$ then $2011 | ab+c$
$$2011 | X.1.3. \cdots. (2011 - 2i).(-2i+2) + (-1)^{i-1} (2i-2) (2i)\cdots.2010$$
if $2011 | a$ then $2011 | -a$.
$$2011 | X.1.3. \cdots. (2011 - 2i).(2i-2) + (-1)^{i} (2i-2) (2i)\cdots.2010$$
$$2011 | 2(i-1)(X.1.3. \cdots. (2011 - 2i).+ (-1)^{i} (2i)\cdots.2010)$$
if $2011 | 2(i-1)a$ then $2011 | a$ since 2011 is prime and $i > 1$.
So the assertion holds for $i = 1,\dots, 1005$. Particularly, for $i = 1005$ we have:
$$2011 | X - 2010$$
$$2011 | X + 1 - 2011$$
$$2011 | X + 1$$
$a_1 - 1$ is divisible by 2011
$a_k a_{k-1} - k$ is divisible by 2011 for $k = 2, 3, \dots, 2010$
Show that $a_{2010} + 1$ is divisible by 2011.
Solution
First we prove the following assertion:
For $k$ odd, then $a_k.2.4.6. \cdots.(k-1) - 1.3.5.\cdots.k$ is divisible by 2011.
For $k$ even, then $a_k.1.3.5. \cdots .(k-1) - 2.4.6.\cdots.k$ is divisible by 2011.
Proof by induction. It can easily be seen for $k=1$ it's true. For $k=2$, we have $2011 | a_2a_1 - 2 = a_2(a_1-1) + (a_2-2)$ So $2011 | a_2 - 2$
Suppose it's true for $k-1$ odd, then for $k$ even:
$2011 | a_k a_{k-1} - k$ which means
$$2011 | 2.4.\cdots.(k-2) (a_k a_{k-1} - k) = 2.4.\cdots.(k-2)a_k a_{k-1} - 2.4.\cdots.(k-2).k$$
$$2011 | a_k (2.\cdots.(k-2)a_{k-1} - 1.3.\cdots.(k-1)) + (a_k.1.3.\cdots.(k-1) - 2.\cdots.(k-2).k)$$
And since 2011 divides the first term by induction hypothesis, then it also divides the second term, which completes the induction step. The proof for $k-1$ even and $k$ odd is similar.
Now, that means for $k=2010$, let $X = a_{2010}$ we have:
$$2011 | X.1.3. \cdots .2009 - 2.4.\cdots.2010$$
We now prove the following assertion for $i = 1,2,\dots,1005$
$$2011 | X.1.3. \cdots. (2011-2i) + (-1)^i (2i) (2i+2)\cdots.2010$$
For $i = 1$ it is true by definition. Now suppose it's true for $i-1$, then for $i > 1$:
$$2011 | X.1.3. \cdots. (2011 - 2i).(2011-2i+2) +(-1)^{i-1} (2i-2) (2i)\cdots.2010$$
if $2011 | a(2011+b) + c$ then $2011 | ab+c$
$$2011 | X.1.3. \cdots. (2011 - 2i).(-2i+2) + (-1)^{i-1} (2i-2) (2i)\cdots.2010$$
if $2011 | a$ then $2011 | -a$.
$$2011 | X.1.3. \cdots. (2011 - 2i).(2i-2) + (-1)^{i} (2i-2) (2i)\cdots.2010$$
$$2011 | 2(i-1)(X.1.3. \cdots. (2011 - 2i).+ (-1)^{i} (2i)\cdots.2010)$$
if $2011 | 2(i-1)a$ then $2011 | a$ since 2011 is prime and $i > 1$.
So the assertion holds for $i = 1,\dots, 1005$. Particularly, for $i = 1005$ we have:
$$2011 | X - 2010$$
$$2011 | X + 1 - 2011$$
$$2011 | X + 1$$
Labels:
induction,
inverse modulo,
modulo,
Number Theory,
sequence
Tuesday, June 21, 2011
Inequality
If $x_1,\dots,x_n$ are real numbers such that $0 \leq x_i \leq 1 \forall i$, and satisfies $x_1 + \dots + x_n = m+r$ where $m$ is an integer and $0 \leq r < 1$, show that:
$$(1+x_1)(1+x_2)\dots(1+x_n) \geq (1+r)2^m$$
Determine the conditions under which equality is achieved.
Solution
For each $i$ such that $x_i = 0$ or $x_i = 1$, we can safely eliminate them from the problem without changing neither the condition nor the inequality. So without loss of generality, we can assume that $0 < x_i < 1$ for all $i$.
Now, we prove by induction on $n$. It is trivial for $n=1$. For $n=2$, we have two cases:
1. The simple case, $x_1 + x_2 = r < 1$ then the inequality also holds trivially
2. The overflowing case, where $1 < x_1 + x_2 = 1 + r$, then:
$$(1-x_1)(1-x_2) \geq 0$$
$$\iff 1+x_1x_2 \geq x_1+x_2 = 1+r$$
$$\iff 1+x_1+x_2+x_1x_2 \geq 2+2r$$
$$\iff (1+x_1)(1+x_2) \geq 2(1+r)$$
Now, for a larger value of $n$, suppose that the inequality is established for $n-1$, and suppose that $x_1 + \dots + x_{n-1} = m + r$. Again we have two cases,
1. The simple case, if $x_n + r < 1$ then $x_1 + \dots + x_n = m+ (r+x_n) < m+1$
$$(1+x_1)\dots(1+x_{n-1})(1+x_n) \geq (1+x_n)(1+r)2^m \geq (1+r+x_n)2^m$$
which follows from the simple case for $n=2$ above.
2. The overflowing case, if $1 < x_n + r = 1 + r_2$ then $x_1 + \dots + x_n = (m+1) + r_2$
$$(1+x_1) \dots (1+x_{n-1})(1+x_n) \geq (1+x_n)(1+r)2^m$$
$$ \geq (1+r_2)2^{m+1}$$
which is similar to the overflowing case from $n=2$ above.
The equality cases can be determined as follows:
If all $x_i$s are zeros or ones, then the equality follows trivially. We assert then at most one of the $x_i$s are strictly between zero and one. Because if there are two of them, then both the simple case and the overflowing case in $n=2$ will never reach equality. The inductive step in the proof also depends on these two cases.
$$(1+x_1)(1+x_2)\dots(1+x_n) \geq (1+r)2^m$$
Determine the conditions under which equality is achieved.
Solution
For each $i$ such that $x_i = 0$ or $x_i = 1$, we can safely eliminate them from the problem without changing neither the condition nor the inequality. So without loss of generality, we can assume that $0 < x_i < 1$ for all $i$.
Now, we prove by induction on $n$. It is trivial for $n=1$. For $n=2$, we have two cases:
1. The simple case, $x_1 + x_2 = r < 1$ then the inequality also holds trivially
2. The overflowing case, where $1 < x_1 + x_2 = 1 + r$, then:
$$(1-x_1)(1-x_2) \geq 0$$
$$\iff 1+x_1x_2 \geq x_1+x_2 = 1+r$$
$$\iff 1+x_1+x_2+x_1x_2 \geq 2+2r$$
$$\iff (1+x_1)(1+x_2) \geq 2(1+r)$$
Now, for a larger value of $n$, suppose that the inequality is established for $n-1$, and suppose that $x_1 + \dots + x_{n-1} = m + r$. Again we have two cases,
1. The simple case, if $x_n + r < 1$ then $x_1 + \dots + x_n = m+ (r+x_n) < m+1$
$$(1+x_1)\dots(1+x_{n-1})(1+x_n) \geq (1+x_n)(1+r)2^m \geq (1+r+x_n)2^m$$
which follows from the simple case for $n=2$ above.
2. The overflowing case, if $1 < x_n + r = 1 + r_2$ then $x_1 + \dots + x_n = (m+1) + r_2$
$$(1+x_1) \dots (1+x_{n-1})(1+x_n) \geq (1+x_n)(1+r)2^m$$
$$ \geq (1+r_2)2^{m+1}$$
which is similar to the overflowing case from $n=2$ above.
The equality cases can be determined as follows:
If all $x_i$s are zeros or ones, then the equality follows trivially. We assert then at most one of the $x_i$s are strictly between zero and one. Because if there are two of them, then both the simple case and the overflowing case in $n=2$ will never reach equality. The inductive step in the proof also depends on these two cases.
Thursday, April 22, 2010
Solution 1: Critical Height
Original problem: http://dharmath.blogspot.com/2010/04/critical-height.html
You have an infinite supply of crystal balls that you take into a building with 1000 stories.
There is a critical height at which if you drop the ball from there, the ball would break. If the ball is dropped from the floors under that critical height, it would not break, but if it's dropped from the floors above, obviously, it breaks.
How many trials minimum do you need in order to determine the critical height?
Advanced version #1: If you only have a supply of $k$ balls, how many trials minimum do you need?
Advanced version #2: What is the strategy that would minimize the expected number of trials, given that you only have $k$ balls, if we treat the critical height as a random variable drawn uniformly from (1,...,1000)?
Note that the two advanced versions are two different questions and thus beget two different strategies.
Clarification: When I say "how many trials minimum do you need in order to determine the critical height" it formally means: find the smallest integer $N$ such that it's always possible to determine the critical height within $N$ trials, regardless of where the critical height is. Naturally, this $N$ will be expressed in terms of $k$ in the case of advanced version #1.
Solution to advanced version #1
First we make an observation that we only care about the number of floors that are possible candidates, and the actual floor height is irrelevant. For example, if we know that the critical height must be in the floor 10 to 30, or if we know that it must be in the floor 510-530, we can employ the exact same strategy in both of those situations. The number of minimum trials needed to solve both scenarios are the same, and any action we do in one scenario is directly translatable to the other scenario. We consider these two scenarios as equivalent problems.
Our second observation is that the possible candidates are always in the form of one contiguous block of floors. We start with a block of 1000 floors (floor 1 to 1000). Every time we drop a ball from a certain floor, say floor $a$ either it breaks or it doesn't break. If it breaks, then our next candidate is floor 1 to $a$, and if it doesn't, then our next candidate is floor $a+1$ to 1000. Every time we drop a ball, we divide one contiguous block into two (possibly unequal) halves and we eliminate one half, so we establish an invariant that our candidates are always one contiguous block of floors.
From the two observations above, we may define a function $f(n,k)$ as the minimum number of trials needed to solve the case with $n$ floors and $k$ balls. Without loss of generality (and for notational ease), we may assume that the floors are floor 1 to $n$.
Suppose our first drop is at floor $a$. As we described above, if it breaks, then we are left with $k-1$ balls to find the critical height among floor 1 to $a$. We need at least $f(a,k-1)$ trials to do this. Otherwise, we still have $k$ balls to find the critical height among floor $a+1,...,1000$. We need at least $f(1000-a, k)$ trials. So in the worst case, we need at least $f(n,k) = \max ( f(a,k-1) , f(n-a,k) ) + 1$ if our first drop is at floor $a$. However, we can choose $a$ to minimize the number of trials.
So:
$$ f(n,k) = \min_{a} \left( \max ( f(a,k-1) , f(n-a,k) ) \right) + 1$$
For $k=1$, if we only have 1 ball, then the only possible strategy is to drop it sequentially from floor 1,2,... until it breaks. Thus $f(n,1) = n-1$ For example, if we know that the critical height is somewhere between floor 1 to 3, then we drop it at floor 1 and 2. If it doesn't break at floor 2, then we don't need to test floor 3 because it already know it breaks at floor 3.
Consider the case of $k=2$. Let $g(n) = f(n,2)$. From the recursion above, we have:
$$ g(n) = \min_{a} \left( \max ( a-1 , g(n-a) ) \right) + 1$$
Let $T(n)$ be the $n$-th triangular number. That is,
$T(0) = 0$
$T(1) = 1$
$T(2) = 1+2 = 3$
$T(3) = 1+2+3 = 6$
...
$T(n) = n(n+1)/2$
And let $T^{-1}(n)$ be the ceiling of the inverse triangular number.
That is
$T^{-1}(0) = 0$
$T^{-1}(1) = 1$
$T^{-1}(2) = T^{-1}(3) = 2$
$T^{-1}(4) = T^{-1}(5) = T^{-1}(6) = 3$
$T^{-1}(7) = T^{-1}(8) = T^{-1}(9) = T^{-1}(10) = 4$
and so on.
We claim that $g(n) = T^{-1}(n-1)$, which we shall prove by induction.
For small $n$ we can verify by hand that we can solve $n$ floors and that it's the minimal amount. In fact, for small $n$, $T^{-1}(n-1)$ agrees with $\log_2 n$ which is the information theoretic lower bound.
Now we proceed by strong induction.
$$ g(n) = \min_{a} \left( \max ( a-1 , T^{-1}(n-a-1) ) \right) + 1$$
Note that $T$ is a monotonically increasing function, which means $T^{-1}(n)$ is monotonically non-decreasing. But since the argument to the function is $n-a-1$, the second half of the max is actually non-increasing.
We wish to find $a$ that minimizes the max of two function, one of which is increasing and another non-increasing. The minimum must happen when the two functions intersect, that is when $a-1 = T^{-1}(n-a-1)$.
$$T^{-1}(n-a-1) = a-1$$
$$n-a-1 \leq T(a-1) = a(a-1)/2$$
$$n-1 \leq a+ a(a-1)/2 = a(a+1)/2 = T(a)$$
$$n-1 \leq T(a)$$
$$T^{-1}(n-1) \leq a$$
So the $a$ that minimizes is $T^{-1}(n-1)$, and for that value of $a$,
$f(n) = (a-1) + 1 = a = T^{-1}(n-1)$.
This completes our proof for $k=2$. For an example, suppose we have 11 floors and 2 balls, then our first drop should be at floor 4. If it breaks then we resort to the linear approach with our one remaining ball to discover which among floor 1,2,3,4 is the critical height. We can do it in 3 trials. If it doesn't break, then we drop it at floor 7. If it breaks at floor 7, then the critical floor must be floor 5, 6, or 7, which we can find in 2 trials. If it keeps not breaking, we drop it at floor 9, then 10. In any case, we will find it within 4 trials.
For case $k=3$, we do the same thing except we replace $T$ with $P$, the $n$ pyramidal number.
$P(0) = T(0) = 0$
$P(1) = T(1) = 1$
$P(2) = T(1) + T(2) = 4$
$P(3) = T(1) + T(2) + T(3) = 10$
...
$P(n) = n(n+1)(n+2) / 6$
The arguments in the proof still hold to establish feasibility and optimality of this strategy.
For general case $k$, we replace $P$ with $H_k$, the $n$-th hyper-pyramidal number:
$$H_k (n) = n(n+1)...(n+k-1) / k! = \binom{n+k-1}{k}$$
And the minimum number of trials is
$$f(n,k) = H_k^{-1}(n-1)$$
You have an infinite supply of crystal balls that you take into a building with 1000 stories.
There is a critical height at which if you drop the ball from there, the ball would break. If the ball is dropped from the floors under that critical height, it would not break, but if it's dropped from the floors above, obviously, it breaks.
How many trials minimum do you need in order to determine the critical height?
Advanced version #1: If you only have a supply of $k$ balls, how many trials minimum do you need?
Advanced version #2: What is the strategy that would minimize the expected number of trials, given that you only have $k$ balls, if we treat the critical height as a random variable drawn uniformly from (1,...,1000)?
Note that the two advanced versions are two different questions and thus beget two different strategies.
Clarification: When I say "how many trials minimum do you need in order to determine the critical height" it formally means: find the smallest integer $N$ such that it's always possible to determine the critical height within $N$ trials, regardless of where the critical height is. Naturally, this $N$ will be expressed in terms of $k$ in the case of advanced version #1.
Solution to advanced version #1
First we make an observation that we only care about the number of floors that are possible candidates, and the actual floor height is irrelevant. For example, if we know that the critical height must be in the floor 10 to 30, or if we know that it must be in the floor 510-530, we can employ the exact same strategy in both of those situations. The number of minimum trials needed to solve both scenarios are the same, and any action we do in one scenario is directly translatable to the other scenario. We consider these two scenarios as equivalent problems.
Our second observation is that the possible candidates are always in the form of one contiguous block of floors. We start with a block of 1000 floors (floor 1 to 1000). Every time we drop a ball from a certain floor, say floor $a$ either it breaks or it doesn't break. If it breaks, then our next candidate is floor 1 to $a$, and if it doesn't, then our next candidate is floor $a+1$ to 1000. Every time we drop a ball, we divide one contiguous block into two (possibly unequal) halves and we eliminate one half, so we establish an invariant that our candidates are always one contiguous block of floors.
From the two observations above, we may define a function $f(n,k)$ as the minimum number of trials needed to solve the case with $n$ floors and $k$ balls. Without loss of generality (and for notational ease), we may assume that the floors are floor 1 to $n$.
Suppose our first drop is at floor $a$. As we described above, if it breaks, then we are left with $k-1$ balls to find the critical height among floor 1 to $a$. We need at least $f(a,k-1)$ trials to do this. Otherwise, we still have $k$ balls to find the critical height among floor $a+1,...,1000$. We need at least $f(1000-a, k)$ trials. So in the worst case, we need at least $f(n,k) = \max ( f(a,k-1) , f(n-a,k) ) + 1$ if our first drop is at floor $a$. However, we can choose $a$ to minimize the number of trials.
So:
$$ f(n,k) = \min_{a} \left( \max ( f(a,k-1) , f(n-a,k) ) \right) + 1$$
For $k=1$, if we only have 1 ball, then the only possible strategy is to drop it sequentially from floor 1,2,... until it breaks. Thus $f(n,1) = n-1$ For example, if we know that the critical height is somewhere between floor 1 to 3, then we drop it at floor 1 and 2. If it doesn't break at floor 2, then we don't need to test floor 3 because it already know it breaks at floor 3.
Consider the case of $k=2$. Let $g(n) = f(n,2)$. From the recursion above, we have:
$$ g(n) = \min_{a} \left( \max ( a-1 , g(n-a) ) \right) + 1$$
Let $T(n)$ be the $n$-th triangular number. That is,
$T(0) = 0$
$T(1) = 1$
$T(2) = 1+2 = 3$
$T(3) = 1+2+3 = 6$
...
$T(n) = n(n+1)/2$
And let $T^{-1}(n)$ be the ceiling of the inverse triangular number.
That is
$T^{-1}(0) = 0$
$T^{-1}(1) = 1$
$T^{-1}(2) = T^{-1}(3) = 2$
$T^{-1}(4) = T^{-1}(5) = T^{-1}(6) = 3$
$T^{-1}(7) = T^{-1}(8) = T^{-1}(9) = T^{-1}(10) = 4$
and so on.
We claim that $g(n) = T^{-1}(n-1)$, which we shall prove by induction.
For small $n$ we can verify by hand that we can solve $n$ floors and that it's the minimal amount. In fact, for small $n$, $T^{-1}(n-1)$ agrees with $\log_2 n$ which is the information theoretic lower bound.
Now we proceed by strong induction.
$$ g(n) = \min_{a} \left( \max ( a-1 , T^{-1}(n-a-1) ) \right) + 1$$
Note that $T$ is a monotonically increasing function, which means $T^{-1}(n)$ is monotonically non-decreasing. But since the argument to the function is $n-a-1$, the second half of the max is actually non-increasing.
We wish to find $a$ that minimizes the max of two function, one of which is increasing and another non-increasing. The minimum must happen when the two functions intersect, that is when $a-1 = T^{-1}(n-a-1)$.
$$T^{-1}(n-a-1) = a-1$$
$$n-a-1 \leq T(a-1) = a(a-1)/2$$
$$n-1 \leq a+ a(a-1)/2 = a(a+1)/2 = T(a)$$
$$n-1 \leq T(a)$$
$$T^{-1}(n-1) \leq a$$
So the $a$ that minimizes is $T^{-1}(n-1)$, and for that value of $a$,
$f(n) = (a-1) + 1 = a = T^{-1}(n-1)$.
This completes our proof for $k=2$. For an example, suppose we have 11 floors and 2 balls, then our first drop should be at floor 4. If it breaks then we resort to the linear approach with our one remaining ball to discover which among floor 1,2,3,4 is the critical height. We can do it in 3 trials. If it doesn't break, then we drop it at floor 7. If it breaks at floor 7, then the critical floor must be floor 5, 6, or 7, which we can find in 2 trials. If it keeps not breaking, we drop it at floor 9, then 10. In any case, we will find it within 4 trials.
For case $k=3$, we do the same thing except we replace $T$ with $P$, the $n$ pyramidal number.
$P(0) = T(0) = 0$
$P(1) = T(1) = 1$
$P(2) = T(1) + T(2) = 4$
$P(3) = T(1) + T(2) + T(3) = 10$
...
$P(n) = n(n+1)(n+2) / 6$
The arguments in the proof still hold to establish feasibility and optimality of this strategy.
For general case $k$, we replace $P$ with $H_k$, the $n$-th hyper-pyramidal number:
$$H_k (n) = n(n+1)...(n+k-1) / k! = \binom{n+k-1}{k}$$
And the minimum number of trials is
$$f(n,k) = H_k^{-1}(n-1)$$
Critical Height
You have an infinite supply of crystal balls that you take into a building with 1000 stories.
There is a critical height at which if you drop the ball from there, the ball would break. If the ball is dropped from the floors under that critical height, it would not break, but if it's dropped from the floors above, obviously, it breaks.
How many trials minimum do you need in order to determine the critical height?
Advanced version #1: If you only have a supply of $k$ balls, how many trials minimum do you need?
Advanced version #2: What is the strategy that would minimize the expected number of trials, given that you only have $k$ balls, if we treat the critical height as a random variable drawn uniformly from (1,...,1000)?
Note that the two advanced versions are two different questions and thus beget two different strategies.
Clarification: When I say "how many trials minimum do you need in order to determine the critical height" it formally means: find the smallest integer $N$ such that it's always possible to determine the critical height within $N$ trials, regardless of where the critical height is. Naturally, this $N$ will be expressed in terms of $k$ in the case of advanced version #1.
Solution to advanced version #1:
http://dharmath.blogspot.com/2010/04/solution-1-critical-height.html
There is a critical height at which if you drop the ball from there, the ball would break. If the ball is dropped from the floors under that critical height, it would not break, but if it's dropped from the floors above, obviously, it breaks.
How many trials minimum do you need in order to determine the critical height?
Advanced version #1: If you only have a supply of $k$ balls, how many trials minimum do you need?
Advanced version #2: What is the strategy that would minimize the expected number of trials, given that you only have $k$ balls, if we treat the critical height as a random variable drawn uniformly from (1,...,1000)?
Note that the two advanced versions are two different questions and thus beget two different strategies.
Clarification: When I say "how many trials minimum do you need in order to determine the critical height" it formally means: find the smallest integer $N$ such that it's always possible to determine the critical height within $N$ trials, regardless of where the critical height is. Naturally, this $N$ will be expressed in terms of $k$ in the case of advanced version #1.
Solution to advanced version #1:
http://dharmath.blogspot.com/2010/04/solution-1-critical-height.html
Labels:
break,
building,
Combinatorics,
crystal ball,
floor,
induction
Thursday, November 19, 2009
3 Sequence Inequality
If $a_i, b_i, c_i$ are sequences of positive numbers for $i = 1,2,\cdots,n$, prove the following inequality:
$\sum (a_i+b_i+c_i) \sum \frac{a_ib_i + b_ic_i+ c_ia_i}{a_i+b_i+c_i} \sum \frac{a_ib_ic_i}{a_ib_i + b_ic_i+ c_ia_i} \leq \sum a_i \sum b_i \sum c_i$
where all summations are taken from $i=1$ to $i=n$. When does equality happen?
$\sum (a_i+b_i+c_i) \sum \frac{a_ib_i + b_ic_i+ c_ia_i}{a_i+b_i+c_i} \sum \frac{a_ib_ic_i}{a_ib_i + b_ic_i+ c_ia_i} \leq \sum a_i \sum b_i \sum c_i$
where all summations are taken from $i=1$ to $i=n$. When does equality happen?
Labels:
arithmetic,
array,
backward induction,
cauchy,
harmonic,
holder,
induction,
Inequality,
mean,
minkowski,
power mean,
Solved
Tuesday, October 27, 2009
Passengers Boarding Airplane, Part Deux
2009 passengers are waiting in a line to board an airplane with 2009 seats. The seats are numbered from 1 to 2009. Each passenger has a boarding pass that has his/her seat number on it. However, these passengers are oblivious to their boarding pass and choose their seats at random, each with a uniform probability from the available empty seats.
What is the probability that everyone's actual seat number and their assigned seat number differ by at most 1? That is, no one sits more than 1 seat away from their assigned seat.
What is the probability that everyone's actual seat number and their assigned seat number differ by at most 1? That is, no one sits more than 1 seat away from their assigned seat.
Friday, October 23, 2009
2 Variable Recursion
This problem is written as an auxiliary lemma for the solution to this problem.
Suppose $f(m,n)$ is a function that is defined for non-negative integers $m,n$ where:
$f(m,n) = 0$ if $m < n$
$f(m,0) = 1 \forall m$
$\displaystyle f(m,n) = \sum_{k=1}^{n} f(k-1,k-1) f(m-k,n-k) + f(m-1,n) \forall m \geq n$
Prove that $f(m,n) = \frac{m-n+1}{m+1} \binom{m+n}{m}$
Suppose $f(m,n)$ is a function that is defined for non-negative integers $m,n$ where:
$f(m,n) = 0$ if $m < n$
$f(m,0) = 1 \forall m$
$\displaystyle f(m,n) = \sum_{k=1}^{n} f(k-1,k-1) f(m-k,n-k) + f(m-1,n) \forall m \geq n$
Prove that $f(m,n) = \frac{m-n+1}{m+1} \binom{m+n}{m}$
Combinatorial Sum Identity
For $m,n > 0$ prove that
$\displaystyle 1 + \sum_{k=1}^{m} \binom{k+n}{k} = \binom{m+n+1}{m}$
Harder version:
$\displaystyle \sum_{k=l}^{m} \binom{k+n}{k} = \binom{m+n+1}{n+1} - \binom{n+l}{n+1}$
$\displaystyle 1 + \sum_{k=1}^{m} \binom{k+n}{k} = \binom{m+n+1}{m}$
Harder version:
$\displaystyle \sum_{k=l}^{m} \binom{k+n}{k} = \binom{m+n+1}{n+1} - \binom{n+l}{n+1}$
Thursday, October 22, 2009
Boys and Girls around the table
$(n+1)$ boys and $n$ girls are seated around a circular table playing a game. One boy started to put a stone on the table, and they subsequently went around the table clockwise. At each child's turn, if that child is a boy, he puts a stone on the table, but if that child is a girl, she takes away one stone from the table. They're finished when everyone has had one turn. If the table ever becomes empty (except before the first boy put his stone), they all lose the game.
Prove that there is a boy such that if he starts, they can complete the round without losing.
Furthermore, prove that there is only one such boy. That is, if any other boy starts, they would lose the game.
Harder version: suppose you now have $m+n$ boys and $n$ girls, with $m$ positive. Prove that there are exactly $m$ boys who could start a non-losing game.
Prove that there is a boy such that if he starts, they can complete the round without losing.
Furthermore, prove that there is only one such boy. That is, if any other boy starts, they would lose the game.
Harder version: suppose you now have $m+n$ boys and $n$ girls, with $m$ positive. Prove that there are exactly $m$ boys who could start a non-losing game.
Subscribe to:
Posts (Atom)