My first attempt - although I wish to try a solution using complex numbers