Changed code

Changed code to use arrays in order to calculate the answers.