  The effect of space inhomogeneities on a diffusing particle is studied in the
framework of the 1D random walk. The typical time needed by a particle to cross
a one--dimensional finite lane, the so--called residence time, is computed
possibly in presence of a drift. A local inhomogeneity is introduced as a
single defect site with jumping probabilities differing from those at all the
other regular sites of the system. We find complex behaviors in the sense that
the residence time is not monotonic as a function of some parameters of the
model, such as the position of the defect site. In particular we show that
introducing at suitable positions a defect opposing to the motion of the
particles decreases the residence time, i.e., favors the flow of faster
particles. The problem we study in this paper is strictly connected to the
classical gambler's ruin problem, indeed, it can be thought as that problem in
which the rules of the game are changed when the gambler's fortune reaches a
particular a priori fixed value. The problem is approached both numerically,
via Monte Carlo simulations, and analytically with two different techniques
yielding different representations of the exact result.
