Made some optimizations to Problems 10 and 12