added code to write solutions to json file.