solved 27
shortened time by limiting checks and evaluating in a better order