# [Python 2], <s>236</s> <s>235</s> 227 bytes # [Python 2], 212 bytes <!-- language-all: lang-python --> def f((x,y),G,M,U=[]): R=1-(len(M[0])-1>x>0<y<len(M)-1);H=[(u+cmp(x,u),v+cmp(y,v)*(u==x))for u,v in G];d,e=0,1 for _ in' '*4*(R<1>((x,y)in H)):J=z,w=x+d,y+e;d,e=-e,d;R|=M[w][z]>(J in U)<f(J,H,M,U+[J]) return R [Try it online!][TIO-k2fb65fu] [Python 2]: https://docs.python.org/2/ [TIO-k2fb65fu]: https://tio.run/##hVRNb@IwFDzjX2E1h9hgEKG0B8AcA0LiQukpG60QGEMFCcoHJdX@d/a9xEmAbrWWeDxPxuPhwXDKkl0Y9K7XjdrSLWMXkXExEXPxLj2fDwhdSKfNDipgc6/r87Yzvoy7o2yUI7Dlw6n0WNpaH09wNuXinLeZOPMmS6W8cL4NI5qKM90HdOIPN0LJrnAIRfg3gDa1m/0mW4yccXE98KacD2byS3zKS2sjspbKj7WV2AwXf@Tc@/S9L3/MZqj5zkdbNhNT9NzyZj4nNFJJGgV0cX1bOtK2batapJMvDS9idcJih22NVgsOEvK27OUKHRJqAzzfSRpFPFpq5J0u5HAb/gOreMUy0v0Ht5Y2Hq3KF7blKWxr7g36H25xm5vPprSuseqwNEVubLk9Y6saV2haTWrUcOvplFy4u@Ia1HDzj6vRZuemhLdbfGrYL4/DKUerv31p7mvxpd0Osh6DGX81HF20@kfCdzTnhtbjxRiidaRWiZqvTiyB/DRimXTi02GfMPtXYHPS@JSYnRjTNNwVPaBziNtwguVDsrYjIFmkgRHJRIS/chWkRxWBMLBBtXGMgAvvSLmI9T0lyimNPZiR0g7tAWhishBUBwNrezBpQXbxASqBJGw9R3R9D59bto/wHMBjBJ0J1Qf@OxByivZBQp@WUZrssieCNmI04UHkBIXUYHnG0vcHtGBvWbMeTsy5USm13NUhVvdaLmq5qOWiltvH8oLl9WfV618 "Python 2 – Try It Online" -15 bytes thx to [Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler) As input, takes a tuple `(x,y)` as jimmy's initial position, a list `G == [(g1x,g1y), ...]` of initial ghost positions, and a list of lists `M` which is the 2-dimensional binary matrix where cells are `0` if they contain "an object" (i.e., `#`) and `1` otherwise. Returns `1` for truthy, `0` for falsey. Loosely speaking, the idea here is that we're going to depth-first recurse over down, left, up, right to seek a border cell.