solved p272 (missing factor of 9) and stumbled across optimization i don't understand