Suppose we're given some absorbing boundary that encloses the origin/starting position, and we take a simple random walk (up/down/left/right with equal probability). For simplicity's sake say we have access to a function which tells us for (x,y) whether it's crossed the barrier
I know simulating this is straightforward, and calculating the expected time until hitting is pretty easy to numerically approximate - but is there a neat algorithmic way to get the exact answer?
I've tried to get something working with DP/DFS but the lack of base-case in the recursion seems to be stumping me. Not sure if there's a way to do this besides simulation/maybe some more in-depth math