Re-wrote solution + added codex

The old solution was not simple enough