Rectangles solution
This is quite an interesting problem
Brute force is quite a valid approach and is the only one I could think of for a while.
Then reviewing Array2D >> isLineAt: another concept came to mind...
- Generate horizontal line segments and validate pairs as possible rectangle sides
- Generate pairs of vertical line segments and validate pairs
- Combinatorially compare the two collections
(not advocating you change yours, just sharing)
Your comment about generate line segment permutations is exactly what this solution is doing (maybe its a bit more obvious now) - it finds square permutations (based on the + corners), and then validates if they actually exist because they are correctly joined by "-" or "|" lines. (Probably worth saying this very text in the class comment actually)
Solution moved and adopted for v3 in PR: https://github.com/exercism/pharo-smalltalk/pull/661