Thanks everyone for the replies. It was very helpful in getting me to understand the logic behind this problem. I forgot to edit my code; $exposures
4 was a mistake and the 4 should have been replaced with counter variables
I didn't include the code to read in the file or print the output of the file, but I am reading in data from a .txt
Once again, big thanks to zek152, Marshall,graff, Neighbour, and FunkyMonk!