Assignment 2. Educational Programming


Problem 1

Solve the checkerboard problem in the puzzle box on page 24 of the reader, except use Javascript Bit instead of Karel. Here are some additional constraints:

  • Bit starts at the bottom left, facing right.
  • You should paint the squares blue instead of placing beepers.
  • Your solution should work with any world that is 2x2 or larger, and the world does not have to be square.
  • Although it is tempting to try and do a "zig-zag" pattern, this is more challenging than writing two functions, one that does one type of row and the other that does the other type of row (i.e., the first function starts with a blue square, then a white square, and the other starts with a white square and then a blue square).
  • There is a very clever trick with the method from the bullet above: the second function can move one square and then call the first function.
  • You can test it in the online Bit simulator https://web.stanford.edu/class/cs208e/simulations/bit/?lang=js&name=checkerboard. Be sure to test on different worlds!

Before:


After:

Problem 2

Scratch is a visual programming language developed through the MIT Media Lab, intended to introduce young students to programming. Although the interface is designed to be appealing to elementary schoolers, Scratch can be used to teach relatively complex concepts.

  1. Load the sample Scratch program here: https://scratch.mit.edu/projects/250424761/ Add additional Scratch code to the program to sort the list generated by this program, using whatever sorting algorithm you prefer (bubble sort is fine, as are other naïve sorts). Note: You will have to create an account
  2. Greek mathematicians took a special interest in numbers that are equal to the sum of their proper divisors, which is simply any divisor less than the number itself. They called such numbers perfect numbers. For example, 6 is a perfect number because it is the sum of 1, 2, and 3, which are the integers less than 6 that divide evenly into 6. Similarly, 28 is a perfect number because it is the sum of 1, 2, 4, 7, and 14. Create a new Scratch project that calculates all perfect numbers in the range 1 to 9999. When a perfect number is found your program should add that number to a list.
  3. You are designing an introduction to programming class for incoming undergraduates with no programming experience whatsoever. Based on your experience with Bit/Karel and Scratch, either choose one of them to use in the first two weeks and justify your choice in a paragraph or two, or argue why you think a different system would be better than using either Bit/Karel or Scratch.