I've got a bit of a problem that I can't figure out. I have 2D arrays of arbitrary sizes, and they contain characters like 'a', 'b', 'c' and so on. I need to break the arrays down into individual horizontal and vertical lines of the same characters, while a single character is only in one "partial array."

For example, let's concider this array:

0 1 2 3 4 . . . 0 a a a a a 1 a 2 a a a a 3 a 4 a . .

Now, the result I want would be something like this:

Array 1: 0 1 2 3 4 0 a a a a a 1 2 3 4 Array 2: 0 1 2 3 4 0 1 a 2 a 3 a 4 a Array 3: 0 1 2 3 4 0 1 2 a a a 3 4

These arrays would of course be converted into coordinate lists for smaller memory. I've tried to think through this for a while, but can't really find any practical ways to do so. Any help is appreciated.