A Train Problem
Published Jul 5, 2022
#math #contests #graphicsFirst blog post, mostly messing around with formatting here. This is powered by MDsveX with custom layouts, with plugin support for syntax highlighting and .
On an infinitely long track, train cars, each with a half chance of containing dynamite, start evenly spaced and all head towards the same direction at distinct constant speeds. When a train catches up to another train , the front of connects to the back of to become a longer train. The new train continues moving at the same speed as . After a long time has passed (such that no new train connections will take place), the trains halt and are inspected. A train is safe if it has two consecutive train cars not carrying dynamite, otherwise it is dangerous. All dangerous trains are removed from the track due to safety hazards, and the total amount of removed train cars is . As tends to infinity, converges to some value. Find this value.
— Modified PROMYS 2022 Q10
Solution
The key idea is to consider the slowest train . Note that:
- All trains behind will at some point all merge into .
- All trains ahead of will never interact with or the trains behind it. So, they form their own system with the same conditions in the problem statement.
We can apply a recursion. Define to be the probability that a train of length (consisting of train cars) is dangerous. Note is the expected value of train cars removed from this train; it’s 0 if it’s not dangerous but if it is.
We have
Here we iterate over all , the possible positions of the slowest train, and sum the expected value (a train of length and a new system with train cars) in each case, and finally take the average.
We simply the recursion by considering :
Remove the weights,
, hence
Lemma
, where is the -th Fibonnaci number.
Note , where is the number of possible length dangerous trains. Consider the first train car. If it contains dynamite, the entire train is dangerous if and only if the rest (without the first train car) of the train is dangerous. If it doesn’t contain dynamite, the next train car must contain dynamite, and then the rest of the train must be dangerous. , and , . Thus .
It remains to determine
Note convergence. Now standard techniques will finish.
Solving yields
Then
Something Else
Here’s a distance estimator for the Sierpenski Pyramid from Syntopia.
// In GLSL, theme is Github Dark
float pyramidDE(float scale, float offset, int iterations, vec3 p){
for (int n = 0; n < iterations; ++n) {
if (p.x + p.y < 0.0){
p.xy = - p.yx;
}
if (p.x + p.z < 0.0){
p.xz = - p.zx;
}
if (p.y + p.z < 0.0){
p.zy = - p.yz;
}
p = p * scale - offset * (scale - 1.0);
}
return length(p) * pow(scale, float(-iterations));
}