Given a string containing only the characters -
, |
, +
and newline determine the longest straight line contained in it. A straight line is either an uninterupted run of -
s and +
s in a single row or an uninterupted run of |
s and +
s in a single column.
So for example:
|
| ----
|
--+--
|
|
There are 3 lines here one vertical, two horizontal, with the vertical line being the longest since it is 6 characters.
Your challenge is to write a program or function which takes a string as input and gives the length of the longest line.
You may assume that the input is perfectly rectangular. That is that every row has the same number of characters. You may also assume that the input contains at least 1 of the non-whitespace characters (-
, |
, and +
).
This is code-golf, answers will be scored in bytes with fewer bytes being the goal.
Test cases
|
| ----
|
--+--
|
|
6
+
1
---|---
|
|
|
4
-
-|||||
-
1
|
|
+----+
6
|+-
-+|
2
|
|
|
| +
|
| |
|
| |
+-+
4
-+|
=> 2 (tests that solutions don't allow lines to wrap from one row/column to the next). \$\endgroup\$124
instead of|
)? At least 3 existing answers appear to do so \$\endgroup\$