Could shorten to codingbat's solution one liner