Solution to interactive program