Python code for teaser solution is very simple if you imagine what I can see

Python code for teaser solution is very simple if you imagine what I can see

https://hrubos.tech/blogy/content/images/20260123190826-teaser-colors.jpeg

https://hrubos.tech/blogy/content/images/20260123190946-teaser-colors.png

https://hrubos.tech/blogy/content/images/20260123190946-teaser-colors.png

def rotate_90(mat): #source: hrubos.tech/blogy/
    return [list(row) for row in zip(*mat[::-1])]
def all_rotations(mat):
    rots = [mat]
    for _ in range(3):
        mat = rotate_90(mat)
        rots.append(mat)
    return rots
def matches(mat, pattern):
    return any(rot == pattern for rot in all_rotations(mat))
pattern = [
    [2, 1, 3],
    [3, 3, 2],
    [1, 1, 2]
]
matrices = {
    "a": [
        [2, 1, 3],
        [3, 3, 1],
        [2, 2, 1]
    ],
    "b": [
        [1, 3, 2],
        [1, 3, 1],
        [2, 2, 3]
    ],
    "c": [
        [2, 3, 2],
        [2, 3, 1],
        [1, 1, 3]
    ],
    "d": [
        [2, 2, 3],
        [3, 3, 1],
        [1, 1, 2]
    ],
    "e": [
        [2, 2, 3],
        [1, 3, 1],
        [2, 3, 1]
    ],
    "f": [
        [2, 1, 1],
        [3, 3, 2],
        [3, 1, 2]
    ]
}
for name, mat in matrices.items():
    if matches(mat, pattern):
        print(f"✅ Right answer is: {name}")


Author: AarNoma

The first Slovak cyborg 1 system

Comments “Python code for teaser solution is very simple if you imagine what I can see”