J, 114 bytes
-.@(-:g)#,=&#[:~.@;@,(g=.|.@|:^:2)([:(#~4<#&>)@(</.~[:+./ .*^:_~1>:|@-/~)$j./@#:I.@,)@:="2]|.!.(u:0)~[:>@,@{<@i:@$
The basic approach is the only mildly interesting part, so I will explain that without breaking down the J mechanics, which are straightforward, could likely be golfed further, though it wouldn't be terribly interesting without a high-level strategy change as well.
- Do the 180 rotation.
- Check where it is equal to the input.
- Also check every possible 2d sliding of the input. You can imagine it as two sheets of paper, keeping the edges aligned, sliding the top one in every direction where there is still any overlap.
- For each of these, we then have a boolean matrix showing which elements are equal. But we only care about connected
1islands of length 5 or more. - To find these, we turn the
1s into coordinates and compute an adjacency matrix, taking their transitive closure, grouping by equal rows, and only keeping "sets" of equal rows of length 5 or more. This is part is done here . - We combine all these valid coordinates we've found for every slid position, take their uniq, and see if it has as many elements as the input. If so, we are Mondrian.
- Finally, we check if the rotation is equal to the input directly, and filter away our input if it is.
J, 114 bytes
-.@(-:g)#,=&#[:~.@;@,(g=.|.@|:^:2)([:(#~4<#&>)@(</.~[:+./ .*^:_~1>:|@-/~)$j./@#:I.@,)@:="2]|.!.(u:0)~[:>@,@{<@i:@$
J, 114 bytes
-.@(-:g)#,=&#[:~.@;@,(g=.|.@|:^:2)([:(#~4<#&>)@(</.~[:+./ .*^:_~1>:|@-/~)$j./@#:I.@,)@:="2]|.!.(u:0)~[:>@,@{<@i:@$
The basic approach is the only mildly interesting part, so I will explain that without breaking down the J mechanics, which are straightforward, could likely be golfed further, though it wouldn't be terribly interesting without a high-level strategy change as well.
- Do the 180 rotation.
- Check where it is equal to the input.
- Also check every possible 2d sliding of the input. You can imagine it as two sheets of paper, keeping the edges aligned, sliding the top one in every direction where there is still any overlap.
- For each of these, we then have a boolean matrix showing which elements are equal. But we only care about connected
1islands of length 5 or more. - To find these, we turn the
1s into coordinates and compute an adjacency matrix, taking their transitive closure, grouping by equal rows, and only keeping "sets" of equal rows of length 5 or more. This is part is done here . - We combine all these valid coordinates we've found for every slid position, take their uniq, and see if it has as many elements as the input. If so, we are Mondrian.
- Finally, we check if the rotation is equal to the input directly, and filter away our input if it is.