Shortened solution to problem 2 by two characters