problem set 4 - implemented function compChooseWord