You are on your honor to make a good-faith effort to solve problems on your own, or with your partners, before using these hints. This typically means at least 10 minutes of brainstorming, attacking the problem with pencil and paper, drawing small diagrams, and so on. The hints are provided with the intention of reducing frustration when course staff support is not available. Remember that the main purpose of this problem set is to help you prepare for Exam 1, so it will defeat that purpose if you use the hints in place of thinking about the problems yourself.
The hints are written in white text on a white background. On most browsers you make the hint visible by moving your mouse over it. If that doesn't work, click your mouse on the screen and drag it over the box: the text will become visible. Try it out on the apparently-empty box below:

If you can read these words, you are doing it correctly.

Question 3

string-to-baudot Hint 1:

Use list-map.




string-to-baudot Hint 2:

Use string->list to convert your argument to a list, and then use list-map on it.




Question 4

Running Time Hint 1:

Check out Example 7.5 (Length) in the course book.




Question 5

rotate-wheel Hint:

You could use list-append to place the cdr of the wheel at the front of your answer. Remember that list-append takes two lists as arguments. To turn X into a one-element list containing X, use (list X).




Question 6

rotate-wheel-by Hint:

Revisit the n-times code from PS3.




Question 7

rotate-wheel-list Hint:

Use list-map to apply rotate-wheel to every wheel in the list.




Question 9

Running Time Hint 1:

The running time of rotate-wheel-list-by depends on both inputs — the wheels passed in and the number of rotates, n. To avoid confusion, use w to represent the number of wheels, p to represent the number of positions in each wheel (fixed as 5 in the problem set, but the procedure we defined would work for any length), and r as the number of rotates to do (the value passed in as n). Express your answer in terms of those three variables.

How much work are we doing per wheel? How many wheels are there?




Running Time Hint 2:

From Example 7.4, list-append has running time in Θ(l) where l is the number of elements in the first list passed to list-append.




Running Time Hint 3:

We are doing Θ(p * r) work for each wheel, and there are w wheels.




Question 10

wheel-encrypt Hint:

The list-map procedure we defined only works on one list at a time, but this problem requires processing two lists at once. Ambitious students will define a twolist-map procedure that takes a procedure and two lists as its inputs. The input procedure should take two inputs. The output of twolist-map is the list that result from applying the input procedure to each of the corresponding elements from the two input lists. For example, (twolist-map + (list 1 7 3) (list 9 5 2)) should evaluate to (10 12 5).

wheel-encrypt Hint 2:

The built-in map procedure already works on any number of input lists! For example, (map + (list 1 7 3) (list 9 5 2)) evaluates to (10 12 5) (so does: (map (lambda (a b) (+ a b)) (list 1 7 3) (list 9 5 2)).)

wheel-encrypt Hint 3:

Use list-map to apply xor to two lists: the Baudot letter (which is just a list of bits) and the list consisting of the first part of each wheel. How can you get the first part of each wheel? map again!




Question 12

do-lorenz Hint 1:

This is a recursive procedure in which the base case is (null? list-of-baudots), the results are combined by (cons ...), and the recursive call is to do-lorenz with each of the four arguments modified as per the text.




do-lorenz Hint 2:

This works as the heart of the recursive call:

 (do-lorenz (cdr list-of-baudots)
            (rotate-wheel-list kwheels)
            (if (= (car mwheel) 1) (rotate-wheel-list swheels) swheels)
            (rotate-wheel mwheel))
... but you'll still need two calls to wheel-encrypt to make things work.







Question 14

brute-force-lorenz Hint 1:

To call something on all of the numbers between 1 and 5, we might do:

(list-map (lambda (i) (something i)) (intsto 5))







brute-force-lorenz Hint 2:

To consider all pairs of numbers between 1 and 5, we might do:

(list-map 
  (lambda (i) 
    (list-map (lambda (j)
                (something i j))
              (intsto 5)))
  (intsto 5))