Find longest consecutive characters in 2D array

Charcoal, 110 bytes


Try it online! Link is to verbose version of code. Takes an array of strings as input. Explanation:


Join the strings with carriage returns (not newlines) and output them without moving the cursor.


Loop over each character in the string.


Collect all of the consecutive characters starting at this position in an array.


If the current character is not a 0 or a carriage return, then check all four directions.


Peek as much as possible in that direction.


Shorten the string until all of the characters are the same.


Save the results in the array.


If the maximum consecutive character was 1, then only push one of the results to the final array, otherwise push all of them.


Reprint the current character, this time allowing the cursor to move.

Clear the input from the canvas.


Find the longest consecutive length.


Loop over the entries with that length.


Output the character and length.


If the length is 1 then output a . otherwise output a direction character. Then move to the start of the next line for the next result.

Jelly, 52 54 bytes


Try it online!

A monadic link that takes a list of strings and returns. list of maximal outputs each in the order n, m, d. A third of the code is to deal with the requirement for dots (last example). Now handles Kevin Cruijssen’s edge case correctly.