Rating:

# Determinant

First, one should observe that the given matrix is always 2*2.

$$
M = \begin{bmatrix}
a & b \\
c & d
\end{bmatrix} \\
P = \begin{vmatrix}
a & b \\
c & d
\end{vmatrix} = ad - bc
$$

## 1 variable
This case is pretty straightforward since there's a single equation with a single variable.

## 2 variables
### Diagonal variables
In this case, we need to find two integers $x$ and $y$ such that their product is equal to a given value:

$$
xy - bc = 1 \implies xy = bc + 1
$$

This may be done in many ways, but as the challenges progress, numbers get larger and simply iterating through all numbers doesn't cut it.

To do it efficiently, we factored the number $bc + 1$, and then iterated through all subsets of those factors to find the combination in which $x, y > g$

### Adjacent variables

Let's assume $a, b$ are given. So we need to find integers $x, y$ such that:

$$
\cases{
ay - bx = 1 \\
x, y > g
}
$$

We can use `egcd` to find arbitrary $x, y$ which don't necessarily satisfy the 2nd condition.

$$
ay - bx = 1 \\
\implies ay + ab - ab - bx = 1 \\
\implies a(\underbrace{y + b}_{y'}) - b(\underbrace{a + x}_{x'}) = 1
$$

Since $a, b > 0$, $x' > x$ and $y' > y$. Let's call this pumping up the value of $x, y$. We can pump up those values so much so that they satisfy the 2nd condition as well.

## 3 variables
Let's assume $a$ is the only given cell. So we need to find integers $x, y, z$ such that:

$$
\cases{
az - xy = 1 \\
x, y, z > g
}
$$

Let $x = 1$ and solve $az - y = 1$ to find the appropriate $y, z > g$ using the method explained earlier. Now we just need to make sure $x > g$ as well. To do so we can pump up $x$ using the method described earlier.

## Result
Solving 40 challenges or so, you'll end up with the flag:
```
| Congrats, you got the flag: S4CTF{5imPl3_PPC_Us1Ng___MatrIx___}
```