Background
A checkered tiling of a rectangular grid is a tiling using some polyominoes, where each region can be colored either black or white so that no two polyominoes sharing an edge has the same color. In graph-theoretic terms, the chromatic number of the adjacency graph is 2.
Terminology adapted from a Fillomino variant recently posted on GMPuzzles.
The following is an example of a checkered tiling, with a possible black-and-white coloring on the right:
+-+-+-+-+-+ +-+-+-+-+-+
|A A A|B|C| |X X X| |X|
+ +-+-+-+ + + +-+-+-+ +
|A|D D|C C| |X| |X X|
+-+-+ + +-+ +-+-+ + +-+
|E|F|D|C|G| | |X| |X| |
+ +-+-+-+ + + +-+-+-+ +
|E E|H|G G| | |X| |
+ + + +-+-+ + + + +-+-+
|E E|H H H| | |X X X|
+-+-+-+-+-+ +-+-+-+-+-+
The following is not a checkered tiling, because it is not possible to color E, H, I with two colors.
+-+-+-+-+-+
|A A A|B|C|
+ +-+-+-+ +
|A|D D|C C|
+-+-+ + +-+
|E|F|D|C|G|
+ +-+-+-+ +
|E E|H|G G|
+ +-+ +-+-+
|E|I|H H H|
+-+-+-+-+-+
Task
Given a tiling, test if it is a checkered tiling.
A tiling can be input as a 2D array or string where each region is represented by a unique single alphanumeric character or integer. For example, the top array can be represented as
AAABC
ADDCC
EFDCG
EEHGG
EEHHH
or
[[0, 0, 0, 1, 2],
[0, 3, 3, 2, 2],
[4, 5, 3, 2, 6],
[4, 4, 7, 6, 6],
[4, 4, 7, 7, 7]]
For output, you can choose to
- output truthy/falsy using your language's convention (swapping is allowed), or
- use two distinct, fixed values to represent true (affirmative) or false (negative) respectively.
Test cases
Truthy
0
00
00
012
0011
2013
2233
01234
56789
ABCDE
FGHIJ
000
010
002
Falsy
01
22
00
12
01
02
01234
05674
0011
0221
3244
3345
Brownie points to the first answer that beats or ties with 17 bytes in Dyalog APL (any version) or 96 bytes in JS (latest browser support, not very well golfed).
00¶12
and01¶02
, which prevent solutions from simply scanning rows once and columns once. \$\endgroup\$00¶12
or a rotation/renumbering in some 2x2 subregion. \$\endgroup\$1, 2, 3, 4, 5, 6
, and not1, 2, 4, 5, 7, 8
? To put it yet another way, can we assume that the third truthy test case will be012
and not013
? \$\endgroup\$