solution to Robot problem