On this page:
8.1 Language
8.2 A Big Change
8.3 Library
8.4 Reading
8.5 Programming Tasks
8.6 Math Tasks
8.7 How We Test Tests
8.8 Turnin

8 Placement 3🔗

8.1 Language🔗

For the following assignment, you must use Racket’s Beginning Student with List Abbreviations language. Go to the Language menu, select Choose Language, and pick the language from the Teaching Languages section.

8.2 A Big Change🔗

From this assignment onward, for the rest of the placement and the course, there’s an important change. Henceforth, you will be graded on the quality and correctness of your code and on the quality and correctness of your tests. Both are important. If you didn’t pay enough attention to writing tests earlier, you should certainly start doing so now.

Part of the process of assessing tests will use an auto-grader. The way we will do this is explained below: How We Test Tests. This means it is especially important to write your tests using check-expect (not as comments) and to follow the instructions given (otherwise the auto-grader will not work, and you may lose credit).

8.3 Library🔗

In Placement 2 you defined the function is-in?. This is built into Racket with the name member. You may use member from now on. Note that member uses equal? to perform its comparisons.

We will also be using characters, which are the atomic elements of strings. Characters are written with a #\ prefix: e.g., #\c, #\s. You can turn strings into lists of characters and vice versa using string->list and list->string.

From now on, for the rest of the placement and the course: in every assignment, you can use any functions defined in that and any previous assignment, as well as libraries permitted in that and previous assignments, unless indicated otherwise—but no other. There may well be built-in functions that do exactly what the assignment asks for, but unless the assignment is expressly about your ability to search, we want you to demonstrate to us that you can write it with the resources we’ve asked you to use.

Some functions in this assignment would benefit from creating a helper function to handle a complex sub-task.

8.4 Reading🔗

In HtDP 2/e, read Part 1, specifically chapter 5.1-5.6, and Part 2, specifically chapter 10.1. You can read past it if you feel the need as you’re doing the assignment.

If you find something unfamiliar, recall that we skipped reading Part 1 so you may need to peek in there to look up something.

8.5 Programming Tasks🔗

Define the following functions.

Note: You must copy the structure definitions given below exactly, to the letter.

8.6 Math Tasks🔗

We are handing out these problems to get a better sense of the mathematical maturity of the student population. Unlike in the previous assignment (Placement 2), we do not expect you to necessarily be able to solve these problems. Please give them your best shot. If you don’t know how to do them, just say so.

Your admission into the class will not depend on your ability to successfuly do these problems: even if you say you don’t know how to do them, it will have no impact. Therefore, there is no value to getting help from others, cheating, etc. Indeed, it would be counterproductive if you did, because it would give us a false sense of the class’s abilities. So please don’t do that.

Please feel free to approximate your answers: e.g., round up to the nearest integer (number or %age). Do show your work!

  1. An AI system is trained to detect photos of lions. The system does not err when the photo actually has a lion, but 5% of photos in which a lion does not appear is detected as having a lion. The algorithm is executed on a set of photos in which 1 out of every 1000 photos actually has a lion. If the AI says a photo has a lion, what is the probability that it actually does have a lion?

  2. An AI system trained to detect a leaf disease in photos of tomato bushes. The system does not err when the photo shows a diseased bush, but 11 out of 100 healthy bushes is also detected as diseased. The disease affects 4 out of every 1000 bushes. If the AI says a photo of a bush is diseased, what is the probability that it really is diseased?

Remember: it’s okay to say you don’t know! It won’t hurt your placement. But do give them a try unless you really have no idea, in which case, it’s fine to say so!

Please remind yoursel of the other instructions about writing up math from Placement 2.

8.7 How We Test Tests🔗

It’s important for you to understand how we test your tests.

What’s the job of a test suite (i.e., set of tests)? It’s to find errors in a program. (Examples help you understand the problem before you start writing code, tests help you catch errors in the program as and after you write it.) In short, test suites are like sorting hats, putting programs in a “good” or “bad” bin.If you are a mathy person, you might call a test suite a classifier.

So here’s how we will test your test suites. We construct a collection of implementations for the problem. One is known to be correct (because we built it that way); we call this a wheat. The rest are known to be incorrect (because we intentionally introduced errors); we call each of these a chaff. Your test suite’s job is to separate the wheat from the chaff (if you haven’t seen that phrase before, read up). That is, we will run your test suite against the wheat and chaffs (which are all programs, just like the one you wrote) and see what happens:This table is not strictly correct. During the semester, we’ll see that a correct wheat may fail for a very interesting reason. But that won’t happen during summer placement.

  

On a wheat…

  

On a chaff…

…all your tests passed

  

Great!
This is what we’re hoping for.

  

Not ideal, but…
…but you may not catch all chaffs, so it may be okay.

…some of your tests failed

  

Uh oh!
We definitely don’t want this. It may mean you’ve misunderstood the problem statement.

  

Great!
This is what we’re hoping for.

The quality of your test suite is then a measure of whether you passed the wheat and how many chaffs you caught. Of course, we can make the latter arbitrarily hard. For instance, we could define a chaff that always works correctly except when the given list has, say, exactly 1729 elements. We won’t do things like that, both because it’s cruel and because real implementations are very rarely buggy in this way. Instead, our chaffs will correspond to typical mistakes that students make.

In short, we will be running your test suite against our implementations. Therefore, it is very important that when you turn in your test suite (see details below), it not be accompanied by your implementation: otherwise, when we try to load ours, DrRacket will complain.

8.8 Turnin🔗

For the math portion, there will be a separate turnin section on Gradescope. Gradescope accepts only images or PDF files. Call this file p3-math; the filename would have a suffix that reflects the file type.

From now on, for the rest of placement and most of the semester, you will turn in multiple code-related files.

One file, named p3-code.rkt, contains the functions named above (it can contain any other helper definitions you like as well). The functions must be named exactly as above and must take parameters exactly as above.

In addition, make a copy of just the test cases for each of the required functions and put them in distinct files, named as follows:

Problem

  

Filename for Tests

valid-words

  

p3-vw.rkt

external-senders

  

p3-es.rkt

unique

  

p3-unique.rkt

after-loan

  

p3-al.rkt

fix-shelves

  

p3-fs.rkt

Please read what follows very carefully, because students routinely make mistakes here. Each of the tests files should:
  • not contain the structure definitions: those will be provided by the wheats and chaffs, so if you include them in your test files, the tests will error

  • not contain implementations of any of the required homework functions (otherwise Racket will not know which implementation to run)—therefore, you will not be able to run this file on its own

  • not contain tests for any helper functions (we will probably not have written the same helpers, so your tests will fail)

  • contain any other definitions needed to run your tests (e.g., if you define a variable and refer to that variable in several tests, we need that definition, otherwise the tests will error; if you define something and use it in the tests for multiple functions, it needs to be in each of those test files)—excluding, of course, the implementation of the required homework functions, which we will be providing

Observe that we are not asking you to modify p3-code.rkt. Leave your helpers, tests, etc. intact in there.

Failure to follow any of these instructions may result in zero credit.

You will upload your work using Gradescope.