# CSAW CTF Quals 2018 - Take an L Writeup

This task is not a common CTF problem, but a very well-known math olympiads and informatics olympiads problem. It’s not very difficult, but I’m doing this writeup because I think it’s one of the problems you have to know before any math or informatics competition.

The server says that we have a grid, with one missing square, randomized every time. We have to fill this grid using only 3-square L-shaped polyominos, of course not overlapping them and using only the space in the grid.

## Problem Analysis

We’ll now prove the following: let be a positive integer, then every grid with one missing square can be tiled using only 3-square L-shaped polyominos.

Proof: let’s prove this by induction: for trivially we can just use one polyomino and cover the remaining 3 squares. So assuming it works for let’s prove it for : without loss of generality we can assume that the missing square lies in the portion of grid between (we’re labeling the squares from top left) and (otherwise we can just rotate the grid) so filling with one polyomino the squares labeled , and and cutting the grid in four parts we obtain 4 different grids with one missing square, and so by the inductive hypothesis we are done.

## Solution

Why have we proven that result? Because the algorithm used in the proof is our solution! We just have to implement it recursively and we are done. The following Python script does the job:

and we can find the flag flag{m@n_that_was_sup3r_hard_i_sh0uld_have_just_taken_the_L}