Given a multi-line string as input containing characters "|"
, "_"
and " "
(space), count the number of cells it contains.
A cell is the following structure of 3 characters by 2 lines:
_
|_|
That is, an underscore on one line (the characters to its right and left don’t matter), and "|_|"
right below it.
Two cells can share the same characters. For example, there are 3 cells here:
_
|_|_
|_|_|
Inputs and outputs
You can assume that the input string will only contain the following characters:
"|"
,"_"
," "
, and"\n"
.You may take a list of strings as input, or a list of lists of chars, instead of a multi-line string.
You may assume that there are at least 2 lines and 3 chars per line.
You may pad each line with spaces so that all lines have the same length.
Test cases
Input Output
_
|_| 1
___
|_| 1
|_| 0
_ _ __ __
|_| _| _|_|| 2
_
|_|_
|_|_| 3
_
| |_
|_|_| 1
_
|_|_
|___| 1
_ _
|_|_|
|_|_| 4
Scoring
This is code-golf, so the shortest answer in bytes wins.
["_","\n",...]
\$\endgroup\$" _ \n|_|\n"
for input #1. \$\endgroup\$