I was inspired by math questions in which one is asked to "Find X" for a given shape. Originally, I was just going to have the challenge be to print the x and y location of the character 'x' in a String. But I supposed that would be too simple. So I considered the context they were normally in, and decided finding the length of a Line next to the x just seemed appropriate.
Given a string input containing a Diagram of ascii 'lines' as well as a single 'x' and potentially junk characters, print the length of the only line that has an 'x' directly adjecent to it.
| | |x | |
|\ | \x | \ |___\
Diagram of a Wobbly Line: IRRELEVANTTEXT____ ____ ____/ \___/ X ;) x
______________ / ____________ \ |/ __________ \| ||/ ________ \|| |||/ ______ \||| ||||/ \|||| |||||/ x ||||| |||||\_____/|||| ||||\_______/||| |||\_________/|| ||\___________/| \_____________/
- The Valid line characters are
\connects the top left and bottom right of itself.
/connects the top right and bottom left of itself.
_connects the left and right of itself
|connects the top and bottom of itself
- A line will always be straight, and only consist of one of the line characters repeated n times.
- The x will always be lowercase, and it will always be the only one in the diagram.
- Adjecent refers to the x being exactly one character above, below, or besides.
- The x will always be next to exactly one Line.
- Tabs will never appear in the input.
- Input and Output may be any acceptable format.
- This is Code Golf, so Shortest Code Wins!
- HAVE FUN. DO IT. ENJOY YOURSELF.