Ominous Omino

From programming_contest
Jump to navigation Jump to search

Introduction

From the 2015 google code jam qualifying round https://code.google.com/codejam/contest/6224486/dashboard#s=p3

The problem asks if you can fit an Omino of X blocks into an R by C grid perfectly.

An omino is a "tetris-like" shape of blocks. You must determine if every type of X omino can be made to fit, using any combination of other X ominos

Difficulty

I'm not smart enough to tell you how to actually solve this problem. However, for the "small" case, the solutions can just be hardcoded. The small case limits X, R, and C to a max of 4.

Thus, it is very easy in both algorithmic complexity and implementation.

Solution

X is 1

The grid can always be filled by 1x1 blocks, no matter the grid size

X is 2

If R * C is an even number, then it always can be filled

X is 3

Here there are two possible ominos, an L shape and an I shape. The min(R, C) must be >= 2 to fit the L omino, and the max(R, C) >= 3 to fit the I omino. Also, R * C must again be a multiple of 3

X is 4

The grid can only be always filled with 4 ominoes when it is 4x4