The point to me is not whether the code 'needs' to be more 'efficient' but determining a way to use a table to do the calculations, as your instructor suggested rather than a brute-force bunch of if...