moderatly slow solution to #10