Functional Problem Solving (CSC 151 2015F) : EBoards

CSC151.01 2015F, Class 26: Preconditions, Revisited


Overview

Preliminaries

Admin

Upcoming Work

Extra Credit Opportunities

Academic

Peer Support

Quiz 6

We'll look at the first problem. I'll probably return it tomorrow.

An "Interesting" Use of Recursion

You wrote something like:

(define sample-and-replace-d!
  (lambda (image left top width height)
    (let ([color1 (random-sample image left top width height)]
          [color2 (random-sample image left top width height)]
          [color3 (random-sample image left top width height)])
      (when (and (< (irgb-distance color1 color2) 50)
                 (< (irgb-distance color2 color3) 50)
                 (< (irgb-distance color3 color1) 50))
        (fill-rectangle! image left top width height
                          (irgb-average-3 color1 color2 color3))))))

We can use recursion!

      (cond
        [(and (< (irgb-distance color1 color2) 50)
              (< (irgb-distance color2 color3) 50)
              (< (irgb-distance color3 color1) 50))
         (fill-rectangle! image left top width height
                          (irgb-average-3 color1 color2 color3))]
        [else
         ; recurse on the top-left quarter
         ; recurse on the top-right quarter
         ; recurse on the bottom-left quarter
         ; recurson on the bottom-right quarter])

Questions

Problem 6: Two approaches

Question too complex to rephrase on the eboard.

> (map list (list "sam" "tyler" "bailey") (list "jones" "bailey" "doodle"))
'(("sam" "jones") ("tyler" "bailey") ("bailey" "doodle"))
> (map list (list 1 2 3) (list 4 5 6))
'((1 4) (2 5) (3 6))

How many test cases on problem 1?

I came up with something like 3 x 2 x 3 x 4 approaches. I combined some things into a test of multiple concepts. I ended up with ten or so.

Are drawings that are not renderable (e.g. because they don't have any points that fall within a typical image) still drawings?

Yes.

Should we put an example in problem 1?

Yes. Show the first few lines of it failing massively on the incorrect implementation.

Should we get rid of the ugly X's?

That would be nice. You can keep beautiful X's, though. We do judge an X by it's appearance. (No, that joke failed miserably.)

What does drawing-render! do?

Puts a drawing on top of an existing image.

You should not need it for this exam.

Should we show experiments for everything?

Yes, that's why there's a section for experiments in every problem.

Lab

Writeup: 1f, 3h