Ad hoc, NOT dynamic programming
2D array manipulation