php algorithm exercises