Shortened solution to problem 2 by one character