final version of machine problem 1