It's currently 7:21 am and my programming class doesn't start till 8:30 am. Instead of sitting here bored looking through threads I felt like trying to teach those that care how to think like a programmer. I'll go ahead and put my very first lesson below, feel free to ask questions if you don't understand. Mechanical Man Program the Mechanical Man to carry out the following objectives: 1) Begin sitting in a chair at an unknown integer number of steps from the wall with his arms lowered. 2) He will stand up and walk forward until he touches the wall with his fingertips. 3) After touching the sall, he will return to his chair. 4) Because the chair is too low for him to sense, he can get to it only by going back exactly the number of steps as he came forward. The Mechanical man possesses the following properities: * He is restricted to carrying out a limited set of instructions. * He does nothing unless given a specific instruction. * He must carry out any instructions he is given one at a time. * He understands only the following instructions: Physical Movement: - Stand up - Sit down - Take one step - Raise arms - Lower arms - Turn right 90 degrees Arithmetic: - Add one - Subtract one - Record total Logic: The mechanical man can decide what instruction he will carry out next on the basis of answers to the following questions: Arithmetic Results: - Is the result positive? or negative? or zero? - Is the result equal to a predetermined amount? Physical status: - Are the raised arms touching anything?
Stand up Raise arms Take one step Add one Is the result negative? Take one step Add one Are the raised arms touching anything? Is the result positive? Record total Lower arms Turn right 90 degrees Turn right 90 degrees Take one step Add one Is the result equal to a predetermined amount? Is the result negative? Take one step Add one Is the result positive? Turn right 90 degrees Turn right 90 degrees Sit down