Converted solutions into .Rnw for pdf output.