Beginning Machine Problems

The problems on this page are the problems I begin with. They teach the commands the machine can understand. They also teach the difficult concept of rigorous attention to detail. They do not have any loops, which limits what can be done.

As far as I know, these problems require the concept of a variable. If students do not have that concept, the problems begin to teach it, but students will of course be struggling with that in addition to everything else they are trying to learn. As far as I know, very young children (e.g., a 5-year-old) simply will not get the concept of a variable, but can get the concept of a loop, taught in the next section.

Starting

Someone has built a machine to follow a few simple commands. With the commands below, what do you think the machine will do?

Hint. When the machine is told to Stop, it stops and does not follow any more commands. Unless it is told otherwise, when it is done with one command, it goes to the next one on the list.

Show what the machine's paper will look like when it is done. Be the machine!

1. Print "Good"
2. Print "morning"
3. Stop


1. Stop
2. Print "Good"
3. Print "afternoon"


1. Go to #3
2. print "Good"
3. Go to #5
4. Print "evening"
5. Stop


1. Print "How are"
2. Go to #5
3. print "fish"
4. go to #3
5. Print "you?"
6. Stop

Variables

n = 3 means to give the value of 3 to n.

[note: I think an understanding of variables is critical to doing this. My 5-year-old could understand a loop but was clueless for any statement involving variables.]

1. n = 3
2. print n
3. Stop


1. n = 3
2. y = 4
3. z = n + y
4. print z
5. print "z"
6. stop


n = n + 1 means, calculate the value of n + 1, using the current value of n, then give n this new value. In other words, "Add 1 to n". If n was zero, it would now equal one; if it was 17, it would now be 18.

1. n = 3
2. n = 2 + n
2. print n
3. Stop


1. w = 3
2. w = w + 1
2. print w
3. Stop

Be the Machinemaster

Be the machine master. Unfortunately, your machine doesn't understand very many instructions, not to mention it can be very picky at times.

1. You can tell it to print a letter or word. Example:

print "Hello"

2. You can tell it to print the value of a variable. Example:

print n

3. You can assign a value to a variable. Example:

n = 3
m = n + 7

4. You can tell the machine to go to a line number. Otherwise, it just goes to the next line. Example:

go to #2.

5. You can tell it to stop.


So you will have to be very clever to get your machine to do what you want. But you can do it (maybe with a little practice and patience).


Write commands that will make the machine print "Hello World!"

Write commands that will make the machine print out 373 divided by 98. Make the machine do the work.

Write your own commands

The Machine

The assumption is that your student is just writing instructions on paper and you are reading and evaluating them. There is a lot to be said for that format. However, I have also built a "machine" to actually follow these instructions. This works well. The basic machine is a typical computer model that follows the instructions written by the student. The "black box" is probably better (as long as the student doesn't need too much output). It is more concrete. You can try it as soon as your student can write any instructions. And there is a lot to be said for starting it that soon.

More Difficult Problems without Loops

The machine doesn't do anything really neat until it starts doing loops. So the following programs are very complex ways of doing very simple tasks. No one would actually write commands these ways.

But, the student has had a lot of new things to learn. The following problems build strength, familiarity, and confidence with what has happened so far. They also further expose the students to the idiosyncracies of the machine.

So, these problems are good for helping the student learn about the machine and what has happened so far. I don't think you want to do all of these before the student leaps into loops, and I have had students do loops without doing these. But it is probably best to do some. And on subsequent days, they are a good warmup problem. It seems to take a while before students become actually bored with these problems.


1. a = 3
2. b = 4
3. a = a + b
4. b = a + b
5. print a
6. print b
7. stop


1. Go to #7
2. n = m + 3
3. Print n
4. Go to #12
5. n = 2
6. print n
7. m = 6
8. Go to #10
9. m = 0
10. Go to #2
11. Print "Good morning"
12. n = 7
13. Stop

Hint: The machine keeps track of what each letter equals. You might want to also. Maybe you could write the values on the side of this paper. Or else you are toast.
1. a = 4
2. b = 2
3. c = 17
4. c = c - 10
5. Go to #15
6. d = 5
7. a = 1
8. Go to #11
9. c = c + 1
10. a = 2
11. c = c + d - 9
12. Go to #17
13. b = 12
14. a = a + c
15. a = 3
16. Go to #6
17. print a
18. Go to #21
19. print c
20. Go to #23
21. print b
22. Go to #19
23. Stop


1. a = 1
2. b = 2
3. c = 3
4. a = a + b
5. b = a + b
6. Go to #8
7. Go to #15
8. c = c + 2
9. a = a - 2
10. Go to #7
11. c = c + a - 3
12. Go to #17
13. b = 12
14. a = a + c
15. print a
16. print b
17. print c
18. Stop


1. Go to #2
2. Go to #3
3. Go to #5
4. Go to #4
5. b = a + b
6. Go to #8
7. Go to #15
8. c = c + 2
9. a = a - 2
10. Go to #7
11. c = c + a - 3
12. Go to #17
13. b = 12
14. a = a + c
15. print a
16. print b
17. print c
18. Stop

Teaching Note

Most of my students ignore my lists of what the machine can do. That's my preference. I supply them just in case the student is interested.