Given a boolean matrix representing my grass field, sheep length \$n\$ and wool thickness \$k\$, you will have to count my sheep.
A sheep is a single independent unbroken line of sheep length \$n\$ and thickness \$k\$.
#|##|# | #
#| | #|#
are all valid sheep for \$n=2,k=1.\$
##|###|## | ##
##|###| ## | ##
##| | ##|##
are all valid sheep for \$n=3,k=2.\$
The diagonal sheep must be composed of horizontal lines of length k.
you are to count occurrences of valid sheep across a given grid.
Sheep will not intersect. You will be guaranteed that \$n,k≥1\$ and \$n ≠ k.\$
so for \$n=2,k=1\$:
##
#
## #
should give 3. Sheep may be right next to each other, and smaller animals may be present in the grid. You should get the max number of sheep that can be recognized from the grid.
Since the grass becomes really short after the sheep graze, your code must be short as well (code-golf).
I/O
You may take the field in any way you like (2D array, string, boolean matrix, so on)
Output must be a single integer ≥ 0.
Test Cases
n=3, k=1
# #
# ### #
#
#
#
#
Output: 3
n=1,k=4
####
####
#
#
####
Output: 3
n=3, k=1
# #
##
###
#
#
Output: 2
n=2, k=5
###
###
###
###
###
###
Output: 1
#
characters an acceptable input method? \$\endgroup\$