P1 refactored, P2 solved via array, recursive solution in progress