solve p014 (takes 30sec.)