[Question]
  [
[Related](https://codegolf.stackexchange.com/questions/241609/is-this-continuous-terrain-part-ii) | [Related](https://codegolf.stackexchange.com/q/199540)
---
Given an ASCII art with `|`, `_`, and , check if you can draw the art in one stroke.
## Description
Your task is, if the ASCII art is representing lines, then check if you can draw the whole art in one stroke, which means:
* without drawing an already drawn line again
* without lifting and continuing the stroke with skipping blocks
## Connection Rules
* A pipe is connected to the left end of the underscore when:
	+ the pipe is left to the underscore `|_`
	+ the pipe is bottom-left to the underscore, but only when it's below a space
```
 _
|
```
* A pipe is connected to the right end of the underscore when:
	+ the pipe is right to the underscore `_|`
	+ the pipe is bottom-right to the underscore, but only when it's below a space
```
_
 |
```
* An underscore is connected to another underscore if it is left/right to it `___`
* A pipe is connected to another pipe if it is above/under it
```
|
|
|
```
A space should not be viewed as a line but as a gap. It can't connect to a pipe or an underscore.
---
So this art can be drawn in one stroke:  
[![Image for clarification](https://i.stack.imgur.com/rZ6TV.png)](https://i.stack.imgur.com/rZ6TV.png)  
(Start at the red cross and end at the blue cross)
# Rules
* [Standard Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) apply
* The program must take the ASCII art as input
* Input will not be empty
* Input can be padded with spaces, so it's rectangular
* [Standard decision problem output](https://codegolf.meta.stackexchange.com/a/19205/96037)
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer wins
## Examples
```
[In]:
 __
|__|
[Out]: True
[In]:
|__|
|__|
[Out]: False
[In]:
 ___
|___|_ |
[Out]: False (because of the space)
[In]:
 _
|_|_
  __|
 |__|
[Out]: True
[In]:
 _
|_|_
  |_|
[Out]: True
[In]:
 _   _
|_| |_|
[Out]: False
[In]:
    _
|_||_|
[Out]: False (the middle pipes are not connected)
[In]:
__
|_|
[Out]: True (begin top-left)
[In]:
___
|_
[Out]: False (the pipe can't connect to the above underscore)
[In]:
___
   |
   |
   |
[Out]: True
[In] (example by DLosc):
 _
|_|_
  |_
[Out]: False (the two pipes are connected to each other, and so is each underscore it the upper pipe, but the central underscores are not (because there's a pipe between them) and neither underscore to the lower pipe (because the pipe is not below a space)
```
Good luck!
  
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 524 bytes
```
def o(A,C=[5]*3,L=[],E=enumerate):d=A.split('\n');Q=A.count;l,c,r=C;return len(L)==Q('|')+Q('_')or any(r<5and[(T:=(Y:=[int(g)-1for g in str(U)])[:4]*all(len(d)>l+u>-1<c+v<len(d[0])!='|_ '[w]==d[l+u][c+v]for u,v,w in zip(Y[4::3],Y[5::3],Y[6::3])))and r==T[0]and(O:=[l+T[1],c+T[2]])not in L and o(A,O+T[3:],L+[O])for U in[3111,3213211,3124122,3102102,1113,1011011,1024013022,1002013002,4112,4124122,4121121,4223123221,2114,2102102,2101101,2203103201]]or[o(A,[i,j,e+(c<'|')])for i,l in E(d)for j,c in E(l)for e in[0,2]if' '<c])
```
[Try it online!](https://tio.run/##dVNda@MwEHz3r9h7klSrxZLd43CjQim9p0AopA9BFcY4Tuvik40iN/TIf8@t7H6l5YLQamdWo8lK7l/8Y2fTX707HNb1Bjp6xa@VPjcnKZ8rbfiNqu3wp3alr1m@Vldn275tPCX3lrCLW8yrbrD@ouUVd@r6wtV@cBba2tI5U@qWkj1hMYaCsM5BaV@om52Xdq3pMld0lSvdWE8f2KnYIP8AjYWtd/SOGabzzJyUbUuD2ppdtvFweSpmVfw8GxGdGPZDkX0BRO@MUmuNFUYjb4LWwJ/5Luj9bXq60lmep4av9Plr/BkiYwy9gFNqiWq4pAt01MZLLQyvMEhjmO18kJlDKA0NWiCR5obPY70wLJx1hwU6FULwVAocGIXMhJQYE4mDI5dykYgwMMosEWmCvEgSGZZYkgkRpmkfTpgKnkmJUqnEJQIZl696ctLiUiZ4RIoaxnROB3u64U@8jmk1C82fDDa8Df/hBvsY0ideTWk7pnWwn3Bpmg0BMqsMO7h6O7R@Cwq0iUIN3kpjx/vRESEkgqKAaF8U@zHj4zymbxh/KysAfwEu8KqOqAlHNAIIu@Dr3s8F@2/UaGD/hXjHj@DJ7BFQREH3MxBOQYMf09Fxo5HRR4BMHkE3@H7w2KKOTt3RIj8VhkXQu/CqJx7T12aelX1f4xt7w6OpjCye8ftqWw7@sYbNYCvfdBZ25RYIxKDJznX2gXAgVedcXXli9Pv14P0s3VBz@F22248wYf9nvif40A//AA "Python 3.8 (pre-release) – Try It Online")
**Input must be rectangular.**
What a mess. The ungolfed version (with long variable names) was a nice 2700 bytes (or so), but I have golfed it down so much that it's down to 524.
Brute-force method. We try to start at every point: for every character that is either a pipe or an underscore, we determine whether:
* it is possible to start at the top of that character if it is a pipe, or the left if it is an underscore, and follow the path of the art (recursively calling the function to move forward, and if there are two or more directions possible, try all of them) until all lines are used up and no line is used more than once; or
* the same is possible with the bottom if pipe, or right if underscore.
When trying to move forward, we store all possible connections according to which character we are currently at and which side of that character we are at, and we use all the connections that are not yet used. If there are none, then it is not possible to draw in one stroke.
]