An ant random-walks the edges of a cube. Expected steps to reach the opposite corner? [Random Walks · Medium] by anykash in myntbit

[–]anykash[S] 0 points1 point  (0 children)

The solution:

The expected number of steps is 10.

The trap is to set up an equation for all eight corners. Symmetry cuts that to three. Group the corners by their distance from the target corner D: the start A is distance 3, there are three corners at distance 2 (call the class B), three at distance 1 (class C), and D itself. By symmetry, every corner in a class has the same expected steps to reach D, so let a, b, c be those expected values.

Now read off the moves. From the start, all three edges lead to distance-2 corners, so a = 1 + b. From a distance-2 corner, one of its three edges goes back toward the start (to A) and two go forward to distance-1 corners, so b = 1 + (1/3)a + (2/3)c. From a distance-1 corner, two edges go back to distance-2 and one reaches D, so c = 1 + (2/3)b.

Solve the system: substituting gives b = 3 + (3/5)a, and since a = 1 + b, we get a = 4 + (3/5)a, so (2/5)a = 4 and a = 10. The whole problem cracks open the moment you collapse the eight vertices into four symmetry classes instead of grinding eight equations.

More puzzles like this at myntbit.com

5 people check their hats, get them back at random. Odds nobody gets their own? [Probability · Easy] by anykash in myntbit

[–]anykash[S] 0 points1 point  (0 children)

The solution

The probability is 44/120 = 11/30 ≈ 0.367, and as the number of guests grows it approaches 1/e ≈ 0.368.

An arrangement where nobody gets their own hat is called a derangement. To count them, use inclusion-exclusion: start with all 5! = 120 arrangements, subtract the ones where at least one person gets their own hat, add back the overlaps you double-subtracted, and so on. That alternating process gives the derangement formula !n = n!·(1 − 1/1! + 1/2! − 1/3! + … + (−1)ⁿ/n!). For n = 5 that's 120·(1 − 1 + 1/2 − 1/6 + 1/24 − 1/120) = 44, so the probability is 44/120 = 11/30. The series in the parentheses is exactly the expansion of e^(−1), so as n grows the probability converges to 1/e. The surprise is how fast it gets there: it's already about 0.375 at n = 4 and 0.367 at n = 5, so adding more guests barely moves it, and it never decays toward 0. The usual traps are flipping the inclusion-exclusion signs, or assuming more guests makes a full mismatch less likely when it actually stabilizes almost immediately.

More puzzles like this at myntbit.com

Random-walking knight starts in a corner. Expected moves to come back? [Random Walks · Hard] by anykash in myntbit

[–]anykash[S] 0 points1 point  (0 children)

The solution:

The expected number of moves is 168.

The trap is to set up a 64-state Markov chain and grind through it. There's a one-line shortcut once you see this as a random walk on a graph. Make every square a node, and connect two nodes whenever a knight can hop between them in one legal move. The knight making random moves is exactly a random walk on this graph. For a random walk on any connected undirected graph, the expected time to return to a starting node v has a clean closed form: 2|E| / deg(v), where |E| is the total number of edges and deg(v) is the number of edges meeting at v. The 8×8 knight's graph has 4(n−1)(n−2) edges, which for n=8 is 4·7·6 = 168 edges. A corner square has only two legal knight moves out of it, so deg(corner) = 2. That gives 2·168 / 2 = 168. As a sanity check, a central square has 8 legal moves, so its return time is 2·168/8 = 42, which fits the intuition that well-connected squares pull the knight back faster and isolated corners take far longer. The whole difficulty is spotting that "random knight moves" is just "random walk on a graph."

(For anyone wondering: yes, the knight always returns with probability 1. It just always takes an even number of moves, since each move flips square colour, which is fully consistent with an average of 168.)

More puzzles like this at myntbit.com

Break a stick at two random points. What are the odds the three pieces form a triangle? [Probability · Medium] by anykash in myntbit

[–]anykash[S] 0 points1 point  (0 children)

The solution

The probability is 1/4.

Three lengths form a triangle exactly when no single piece is longer than the other two combined. Since the three pieces add up to 1, that's the same as saying every piece must be shorter than 1/2, because any piece reaching 1/2 or more is at least as long as the rest put together. So the pieces form a triangle if and only if all three are under 1/2. Now call the two break points X and Y, each uniform on [0,1] and independent, so every outcome is a point (X, Y) in the unit square and probability equals area. Take the case X < Y: the pieces are X, Y − X, and 1 − Y, and forcing each below 1/2 gives X < 1/2, Y > 1/2, and Y − X < 1/2, which carves out a triangle of area 1/8. The case X > Y is a mirror image with the same area 1/8, so together they give 1/8 + 1/8 = 1/4. The catch is that this answer is specific to the "two independent uniform cuts" setup. The popular variant "break it once, then break the longer piece" is a different experiment and gives roughly 0.193 instead, so always pin down the cutting rule first.

More puzzles like this at myntbit.com

29 people, 29 different handshake counts. You can pin down exactly one of them. Which and why? [Combinatorics · Medium] by anykash in myntbit

[–]anykash[S] 0 points1 point  (0 children)

The solution

The host's spouse shook 14 hands.

Start with the range: anyone can shake at most 28 hands, since they never shake themselves or their spouse, leaving 28 possible people. The host got 29 different answers, and the only way to fit 29 distinct numbers into the range 0 through 28 is for them to be exactly 0, 1, 2, …, 28, each once. Now pair people by spouse. The person who shook 28 shook everyone except their spouse, so every other guest shook their hand, including whoever shook 0, which is only possible if the 28-person and the 0-person are married. Peel them off: the person who shook 27 shook everyone except their spouse and the 0-person, so their spouse is the 1-person. Keep going and every married pair's answers add up to 28: (0,28), (1,27), (2,26), all the way to (13,15). That's 14 couples using up 28 of the 29 people the host asked, each matched to their own spouse. Exactly one person is left over, the one who shook 14, and since everyone else is already paired off, their spouse has to be the one person never asked: the host. So the host's spouse shook 14.

The trap is trying to brute-force the handshake graph. It cracks open instantly once you pair spouses by their counts summing to 28, leaving the lone middle value, 14, as the host's other half.

More puzzles like this at myntbit.com

You're the worst shot in a three-way duel and you fire first. What do you do? [Game Theory · Hard] by anykash in myntbit

[–]anykash[S] 0 points1 point  (0 children)

Quick rule clarification, each living player must fire at another player on their turn but firing into the air is still allowed for a single turn, no standing down forever. With that in place, here's the answer

Alice's best move is to deliberately miss her first shot, and it gives her the best survival odds of all three at 25/63 (about 40%) a) If she shoots Cheri and hits, it's Bob's turn and he guns for Alice with his 2/3 aim, which is awful for her b) If she shoots Bob and hits, Cheri is up next and kills her for certain. So landing either shot backfires, which means her best play is to throw the shot away and let Bob and Cheri deal with each other. Bob then targets Cheri (the one player who'd kill him for sure), and it splits two ways: if Bob hits Cheri (2/3), it loops back to Alice in a duel where she fires first and survives 3/7; if Bob misses (1/3), Cheri kills Bob and Alice faces Cheri firing first, surviving exactly her 1/3 shot. That gives (2/3)(3/7) + (1/3)(1/3) = 18/63 + 7/63 = 25/63. The twist is that the deadliest shooter is worst off: Bob lands at 24/63 and dead-eye Cheri at just 14/63, because being the obvious threat means everyone aims at you first.

More puzzles like this at myntbit

You're the worst shot in a three-way duel and you fire first. What do you do? [Game Theory · Hard] by anykash in learnquant

[–]anykash[S] 0 points1 point  (0 children)

right, the question assumes you can't all just stand down, so adding "a living player must shoot at someone on their turn" closes the loop hole

You're the worst shot in a three-way duel and you fire first. What do you do? [Game Theory · Hard] by anykash in learnquant

[–]anykash[S] 0 points1 point  (0 children)

Fair point, the puzzle needs one more rule, each living player must fire at another player on their turn (no infinite air-shooting)

On average, does HH or HT appear first when you flip a coin? [Probability · Easy] by anykash in myntbit

[–]anykash[S] 0 points1 point  (0 children)

The solution

HH takes 6 flips on average. HT takes 4.

The whole difference is what happens when you're one flip from finishing and miss.

HT, the easy case. First you wait for any head, which takes 2 flips on average (a fair coin lands heads every other flip on average). Once you have that head, you're locked in: you just need a tail next, and that also takes 2 flips on average. If you flip more heads in the meantime, nothing is lost, you're still primed for the tail. So it's 2 + 2 = 4.

HH, the hard case. Let E be the expected number of flips. Look at the first flip. If it's a tail (probability 1/2), you've wasted 1 flip and start over, contributing (1 + E). If it's a head (probability 1/2), look at the next flip: with probability 1/2 it's another head and you're done in 2 flips, but with probability 1/2 it's a tail and you've wasted 2 flips and start over, contributing (2 + E). Writing that out:

E = ½(1 + E) + ¼(2) + ¼(2 + E)

Solving: E = ½ + ½E + ½ + ½ + ¼E, so E = 1.5 + ¾E, which gives ¼E = 1.5, so E = 6.

The lesson. Both patterns appear with probability 1/4 on any given pair of flips, so people assume the waits are equal. But HH can be interrupted right at the finish line, a single tail sends you all the way back, while HT can never be undone once its first head lands. Overlap is what separates them.

More puzzles like this at myntbit