Question
You have a row of n cells indexed 0..n-1. A token starts at cell s. Each step it moves left or right by one cell, each with probability 1/2, EXCEPT at the two ends which are absorbing: cell 0 and cell n-1 stop the walk. Return the expected number of steps until absorption, rounded to 6 decimal places. Constraints: 2 <= n <= 100000, 0 <= s <= n-1. (For an interior start the answer has the closed form s*(n-1-s).)
expected_steps_to_absorb(n: int, s: int) → float[3,1]out1State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.