programming assignment 3, fixing the state validation for all, adding solution to third problem