560 likes | 650 Views
A201 (I201, A597) Introduction to Programming. Adrian German (dgerman@indiana.edu). Office: Lindley Hall (LH) 201D. Class home page containing ALL the details:. http://www.cs.indiana.edu/classes/a201. Please check the “What’s New” part of the web page every day!.
E N D
A201 (I201, A597) Introduction to Programming Adrian German (dgerman@indiana.edu) Office: Lindley Hall (LH) 201D Class home page containing ALL the details: http://www.cs.indiana.edu/classes/a201 Please check the “What’s New” part of the web page every day!
The purpose of this class: - to get to know each other better
The purpose of this class: - to get to know each other better - to understand programming in Java
The purpose of this class: - to get to know each other better - to understand programming in Java - to improve our problem solving skills
The purpose of this class: - to get to know each other better - to understand programming in Java - to improve our problem solving skills A reminder:
The purpose of this class: - to get to know each other better - to understand programming in Java - to improve our problem solving skills A reminder: Education is what remains after we forget what we learned in school.
The purpose of this class: - to get to know each other better - to understand programming in Java - to improve our problem solving skills A reminder: Education is what remains after we forget what we learned in school. But we have to learn it first!
What is Programming? What does it look like?
What is Programming? What does it look like? Let’s work out some examples.
First Problem You are given two (different length) strings
First Problem You are given two (different length) strings that have the characteristic that they both take exactly one hour to burn.
First Problem You are given two (different length) strings that have the characteristic that they both take exactly one hour to burn. However, neither string burns at a constant rate.
First Problem You are given two (different length) strings that have the characteristic that they both take exactly one hour to burn. However, neither string burns at a constant rate. Some sections of the strings burn very fast; other sections burn very slowly.
First Problem You are given two (different length) strings that have the characteristic that they both take exactly one hour to burn. However, neither string burns at a constant rate. Some sections of the strings burn very fast; other sections burn very slowly. All you have to work with is a box of matches and the two strings.
First Problem You are given two (different length) strings that have the characteristic that they both take exactly one hour to burn. However, neither string burns at a constant rate. Some sections of the strings burn very fast; other sections burn very slowly. All you have to work with is a box of matches and the two strings. Describe an algorithm that uses the strings and the matches to calculate when exactly 45 minutes have elapsed.
Second Problem A farmer lent the mechanic next door a 40-pound weight.
Second Problem A farmer lent the mechanic next door a 40-pound weight. Unfortunately, the mechanic dropped the weight and it broke into four pieces.
Second Problem A farmer lent the mechanic next door a 40-pound weight. Unfortunately, the mechanic dropped the weight and it broke into four pieces. The good news is that, according to the mechanic, it is still possible to use the four pieces to weigh any quantity between one and 40 pounds on a balance scale.
Second Problem A farmer lent the mechanic next door a 40-pound weight. Unfortunately, the mechanic dropped the weight and it broke into four pieces. The good news is that, according to the mechanic, it is still possible to use the four pieces to weigh any quantity between one and 40 pounds on a balance scale. Note: you can weigh a 4-pound object on a balance by putting a 5-pound weight on one side and a 1-pound weight on the other.
Third Problem A captive queen weighing 195 pounds,
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds,
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds, were trapped in a very high tower.
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds, were trapped in a very high tower. Outside their window was a pulley and rope with a basket fastened on each end.
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds, were trapped in a very high tower. Outside their window was a pulley and rope with a basket fastened on each end. They managed to escape
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds, were trapped in a very high tower. Outside their window was a pulley and rope with a basket fastened on each end. They managed to escape by using the baskets and a 75-pound weight they found in the tower.
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds, were trapped in a very high tower. Outside their window was a pulley and rope with a basket fastened on each end. They managed to escape by using the baskets and a 75-pound weight they found in the tower. How did they do it?
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds, were trapped in a very high tower. Outside their window was a pulley and rope with a basket fastened on each end. They managed to escape by using the baskets and a 75-pound weight they found in the tower. How did they do it? The problem is that anytime the difference in weight between the two baskets is more than 15 pounds, someone might get killed.
Third Problem A captive queen weighing 195 pounds, her son weighing 90 pounds, and her daughter weighing 165 pounds, were trapped in a very high tower. Outside their window was a pulley and rope with a basket fastened on each end. They managed to escape by using the baskets and a 75-pound weight they found in the tower. How did they do it? The problem is that anytime the difference in weight between the two baskets is more than 15 pounds, someone might get killed. Describe an algorithm that gets them down safely.
Robot() Shakey the Based on a character created by Suzanne Menzel
The place is here (RH100) the time is in the future. You are about to enter the sixth dimension… Hang in there! Hang in there!
red lines are solid walls (nothing can go through)
(0,0) (0,1)
(0,0) (0,1) (0,2)
(0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
Robotshakey; (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
shakey = new Robot(); shakey shakey new Robot(); Robotshakey; shakey = new Robot(); (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
shakey Robotshakey; shakey = new Robot(); shakey = new Robot(); shakey.placeAt(2, 1, “North”); (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) shakey (2,0) (2,1) (2,2)
Robotshakey; shakey = new Robot(); shakey.placeAt(2, 1, “North”); (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2) a Robot (only) knows how to: turnleft() moveforward()
shakey.left(); Robotshakey; shakey = new Robot(); shakey.placeAt(2, 1, “North”); (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
Robotshakey; shakey = new Robot(); shakey.placeAt(2, 1, “North”); shakey.left(); shakey.forward(); (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2)
Robotshakey; shakey = new Robot(); shakey.placeAt(2, 1, “North”); shakey.left(); shakey.forward(); (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2) a Robot (only) knows how to: turnleft() moveforward()