Challenge:
Take a rectangular figure consisting of the two characters #
and (whitespace, ASCII-32), and identify which direction the lines are. The options are: 'Vertical', 'Horizontal', 'Left Diagonal' and 'Right Diagonal'.
Input:
The input will be a figure of size n-by-m where 5 <= m,n <= 20. There will be two spaces between horizontal lines, two spaces between lines in the horizontal/vertical direction. Note that the lines doesn't have to start or end in a corner. The input will look like this:
Horizontal:
##########
##########
##########
Vertical (note that there can be leading spaces):
# # #
# # #
# # #
# # #
# # #
Left diagonal:
# # #
# #
# #
# # #
# #
Right diagonal:
# # # # #
# # # #
# # # # #
# # # # #
# # # #
- The input format is optional. You may substitute the visual newlines by
\n
, or create the grid by concatenating the rows with ASCII-10 (relevant for MATLAB/Octave). - You may not take the input as numbers (
1/0
) instead of#
and0
.
Output:
The output shall be 4 distinct values/outputs for each of the four different cases. It can for instance be 1,2,3,4, or V,H,L,R.
Test cases:
There will be an asterisk over the top left corner of the figure, and an asterisk below the bottom left corner of the figures. This is to indicate where the figure starts and ends.
Horizontal:
*
#####
#####
*
*
###########
*
*
##########################
##########################
##########################
*
Vertical:
*
# # # #
# # # #
# # # #
# # # #
# # # #
*
*
# # # # # #
# # # # # #
# # # # # #
# # # # # #
# # # # # #
*
Left diagonal
*
# # #
# #
# #
# # #
# #
*
*
# # # # #
# # # #
# # # #
# # # # #
# # # #
# # # #
*
*
# # #
# # # #
# # #
# # #
# # # #
*
Right diagonal
*
# # # # #
# # # #
# # # # #
# # # # #
# # # #
*
*
# # # # # # #
# # # # # # #
# # # # # #
# # # # # # #
# # # # # # #
*
This is code-golf so the shortest code in each language wins.
MaxDetect@*Radon@*Blur@*Graphics@*Text
, but I can't imagine it'd be at all competitive \$\endgroup\$