One of the Math Practice Standards (#5) refers to using appropriate tools strategically. I would like to show that computer programming is excellent at teaching students to do just that. Let me use a simple example.
It is Halloween! Karel needs to pick up three eyeballs and enter his home square!
Below are six different programs which all solve the given task. However, looking at their differences reveals the ability of the student to use the most appropriate tools to solve the given problem. Program #1 uses just elementary commands without any programming logic (really bad code!):
Program #2 takes advantage of a repeating pattern, but it fails to realize that there is one additional repeating pattern on a finer scale:
Program #3 takes advantage of two levels of repeating patterns:
Program #4 uses an if-else statement to reduce the logic to a single nested loop:
Program #5 uses an if-else statement to reduce the logic to a single loop. One extra advantage of this approach is that the eyeballs can be anywhere in the row connecting the robot with the home square:
Last, Program #6 also works for randomly distributed objects, but moreover it does not require the home square to be exactly 12 steps away from the robot – it is more general than Program #5: