Actions

Work Header

probability encounters

Summary:

In the giant N x N grid of the Yiling marketplace, Lan Wangji and A-Yuan are but two particles undergoing Brownian motion.
Thank the lucky stars that A-Yuan bumps into exactly the right person.

((This work used to be called "chance encounters and encounters by chance" if you're looking for that btw))

Notes:

(See the end of the work for notes.)

Work Text:

The Yiling marketplace is, for all intents and purposes, an N x N grid (1 ≤ N ≤ 100) with the southwest corner at (0,0) and the northeast corner at (N, N).

On one of their rare excursions from the Burial Mounds, Wei Wuxian and A-Yuan visit the vegetable vendor at lattice point (A, B) (0 ≤ A, B ≤ N) to purchase potatoes. While Wei Wuxian haggles the exorbitant, totally unfair prices of the clearly subpar produce, A-Yuan being A-Yuan being a literal toddler starts to get a little bored… 

In any given time frame, A-Yuan walks at random to a lattice point adjacent to his own. For example, at time t=0 minutes, A-Yuan starts at (A, B) and can walk to either (A-1, B), (A, B-1), (A+1, B), or (A, B+1) given that they are on the grid. A-Yuan would never, say, travel from (0, 6) to (-1, 6).

Meanwhile, the visiting Lan Wangji has also somehow found his way into the market square. At time t=0, Lan Wangji is at point (C, D) distinct from (A, B). Being new to the place and wanting to look around, Lan Wangji undergoes a random walk identical to that of A-Yuan.

It takes Wei Wuxian T minutes (1 ≤ T ≤ 50) to notice that A-Yuan is missing and negligible time to track him down.

An encounter occurs when two characters arrive at the same point at the same time. If A-Yuan encounters Lan Wangji, he will crash into Lan Wangji’s leg like a moth to a lamp and start bawling his eyes out, effectively stopping both of their random walks. Then Lan Wangji, Wei Wuxian, and A-Yuan will have dinner together and Lan Wangji will return to the Burial Mounds with them. If Wei Wuxian encounters A-Yuan, he will give A-Yuan a light scolding and they will head home without having met with Lan Wangji, missing an opportunity to advance the romantic subplot. (If Lan Wangji and Wei Wuxian arrive at the same point, they will merely pass by one another with no change in behavior because Wei Wuxian is in the middle of a frantic search and it is a really crowded marketplace. This is for no reason other than to make my life easier as the problem writer).

Calculate the probability, expressed as a decimal rounded to four places, that A-Yuan bumps into Lan Wangji before Wei Wuxian finds him at time t=T.

Input: Six space-separated characters: N, T, A, B, C, D

Output: One decimal value to four places

Sample:

Input

2 2 0 0 2 2

Output

0.1667

Notes:

I have a solution to this I swear, I'm just too lazy to write it up.
Anyways, feel free to discuss in the comments. See if you can beat my O (N^2 * T) solution!

Series this work belongs to: