On this page:
8.3.1 Placement Assignments
8.3.2 Placement 1
8.3.2.1 Language and Software
8.3.2.2 Questions
8.3.2.3 Library
8.3.2.4 Reading
8.3.2.5 Task
8.3.2.6 Turnin
8.3.3 Placement 2
8.3.3.1 Language
8.3.3.2 Library
8.3.3.3 Reading
8.3.3.4 Task
8.3.3.5 Work Expectations
8.3.3.6 Turnin
8.3.4 Placement 3
8.3.4.1 Language
8.3.4.2 Library
8.3.4.3 Reading
8.3.4.4 Task
8.3.4.5 Turnin
8.3.5 Placement 4
8.3.5.1 Goal
8.3.5.2 Language
8.3.5.3 Library
8.3.5.4 Reading
8.3.5.5 Task
8.3.5.6 Turnin
8.3.5.7 Learning by Contributing

8.3 

8.3.1 Placement Assignments

All the reading is from How to Design Programs, second edition.

8.3.2 Placement 1
8.3.2.1 Language and Software

For the placement process, you will be using the Racket programming language. Follow the link to download Racket. Installing it will also install the DrRacket programming environment, in which you can write and run your programs. The first part of the reading (see below) explains how to use DrRacket.

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

8.3.2.2 Questions

If you have questions, you can use our Piazza board. Please do not post answers or ask questions in a way that reveals your answers (for this and all future assignments). Read the policy on Honesty and Sharing: you’re responsible for adhering to it.

If you have prior programming experience, you may find this assignment quite easy. That’s because the assignments are designed so even students who haven’t had access to a computing course before can still have a fair shot at trying out. The assignments will grow in complexity, so you may well find yourself wanting to use Piazza later.

8.3.2.3 Library

To do these assignments, make sure you add the following line at the top of your program:
(require 2htdp/image)

8.3.2.4 Reading

Read the Prologue of HtDP 2/e. You won’t need all the content of this part to do the work below (the first portion, through the “Arithmetic and Arithmetic” section, should suffice), but from the next assignment onward you will be defining functions and using conditionals (covered in the rest of the part), so you may find it useful read ahead.

If you want to learn more about Racket’s support for images, see the Quick Introduction.

If you are new to programming: people learn programming by actually writing programs and running them. As you read, type in the code in the document, see how it works, change it a little and see what happens. Actually trying the code in the assigned reading will be essential for you to get comfortable with the material. Do not passively “read” the material: you will get far less out of it than you imagine!

8.3.2.5 Task

Create flags of the following countries:
  • Vietnam

  • Chile

  • Suriname

  • Saint Lucia

  • Turkey

You should create these flag images using the Racket image primitives (for rectangles, stars, etc.), not by finding the images and pasting them in. You are, however, welcome to use a Web search to figure out what the flags look like.

You may pick the dimensions of your flag, but please make it large enough for us to see (with a width of at least 100), but preferably not so large that we need to scroll a lot to see them all.

For maybe the only time this summer or during the semester, we will not judge you on absolute correctness (e.g., checking whether you got the precise ratios of the different parts right). We’re going to visually eyeball it for general adherence. Of course, feel free to geek out on the vexillological details as much as you wish!

8.3.2.6 Turnin

Please write a series of expressions in a single file such that, when the file is Run, the flags appear in the interactions area. If you do use define to give them names, make sure to use these names so that the criterion above is met.

Please name your file p1.rkt (“papa-one-dot-romeo-kilo-tango”). Failure to use the correct name or otherwise follow these instructions may result in zero credit. (Note: Google Drive will automatically rename your file(s) to include your name. This is fine.)

Upload your file here. You will need to be logged into the Google@Brown domain to upload: it will not work with a regular Google (…@gmail.com) account.

8.3.3 Placement 2
8.3.3.1 Language

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

8.3.3.2 Library

To do these assignments, make sure you add the following line at the top of your program:
(require 2htdp/image)

You may also find some string functions useful.

8.3.3.3 Reading

Read Part 2 of HtDP 2/e, specifically chapters 8 and 9 through 9.1 (you don’t need to go further).

If you find something unfamiliar (e.g., the material references if), note that we skipped reading Part 1 so you may need to peek in there to look it up.

8.3.3.4 Task

Define the following functions. Even if you think they correspond to a function that already exists, write it yourself. We’re testing your ability to program, not to read documentation!

8.3.3.5 Work Expectations

From this assignment onward, for the rest of the placement and the course, you will be graded on both the quality of your code and the correctness of your answers. The latter will be (mostly) graded by computer, so it’s vital you follow the problem specification exactly. The former will be (mostly) graded by hand, and we will look for how well you have presented the parts expected by the Design Recipe. Both parts are equally important.

8.3.3.6 Turnin

Please turn in a single file that contains the five 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. Please name your file p2.rkt. (Note: Google Drive will automatically rename your file(s) to include your name. This is fine.)

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

Upload your file here. You will need to be logged into the Google@Brown domain to upload.

8.3.4 Placement 3
8.3.4.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.3.4.2 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.

We will also be using characters, which are the 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 vice versa with list->string.

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

8.3.4.3 Reading

Read Part 2 of HtDP 2/e, 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.3.4.4 Task

Define the following functions.

8.3.4.5 Turnin

This time you will turn in two files.

One file, named p3-code.rkt, contains the five 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. (Note: Google Drive will automatically rename your file(s) to include your name. This is fine.)

In addition, make a copy of just the test cases for the required functions—not their implementations, nor tests for any other functions—and put them in another file, p3-tests.rkt. Turn this in as well.

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

Upload your file here. You will need to be logged into the Google@Brown domain to upload.

8.3.5 Placement 4
8.3.5.1 Goal

Functional programmers don’t actually spend all day writing recursive functions over lists. Rather, they use so-called “higher-order” functions, which are functions that consume other functions, to do that kind of work. That is, in functional programming, a loop is just a function, and different kinds of loops correspond to different kinds of higher-order functions. In this assignment you will learn about some of these “looping functions”.

There is also a second part [Learning by Contributing] to this assignment. Please see below.

8.3.5.2 Language

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

8.3.5.3 Library

You will not need more than the following higher-order functions:
  • map

  • filter

  • foldl

  • foldr

  • andmap

  • ormap

You may also use any library function you were permitted to use on prior assignments, particularly in Placement 3.

8.3.5.4 Reading

You will read from Part 3 of HtDP 2/e, specifically
  • 14.1

  • 14.2

  • 14.4

  • 15.1

  • 15.4

  • 16.1

  • 16.2

  • 16.5

You can read the rest if you feel the need as you’re doing the assignment.

8.3.5.5 Task

Define the same functions as in Placement 3. However, you are not allowed to use explicit recursion; you must use one of the functions listed in Library in its stead. You are of course welcome to write helper functions.

You are welcome to reuse anything appropriate that you wish from your Placement 3 submission, e.g., purpose statements and tests. You do not need to write templates.

We do expect you to do a thorough job on testing, building on the feedback you received for Placement 3.

Note that unique is a bit challenging and it’s okay if you can’t complete it after you’ve spent a while trying.

8.3.5.6 Turnin

You will again turn in two files.

One file, named p4-code.rkt, contains the five functions required above (it can contain any other helper definitions you like as well). The functions must be named exactly as decribed and must take parameters exactly as described. (Note: Google Drive will automatically rename your file(s) to include your name. This is fine.)

In addition, make a copy of just the test cases for the required functions—not their implementations, nor tests for any other functions—and put them in another file, p4-tests.rkt. Turn this in as well.

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

Upload your file here. You will need to be logged into the Google@Brown domain to upload.

8.3.5.7 Learning by Contributing

We have added another part to Placement 4’s task. It’s based on Contributing Student Pedagogy, which enhances learning. It will also help us gauge what you’ve struggled with, helping us improve future versions of this class.

Please do this task after you have completed and submitted your assignment. (It will not require any changes to the files you turned in.)

Please visit www.quizi.us and create an account. From there, enroll in the Accelerated Introduction to Computer Science class and select the Racket Quiz. The exercise will ask you to do two things:
  • Write a small program (please pay attention to the format), intended for your fellow students. Don’t include a purpose statement or give it a meaningful name and certainly do not include any tests! For brevity, you can also leave out any data definitions already seen in class. For most programs, you can include just executable code and, if you think it helps, a contract.

    For this part, you are welcome to run it in DrRacket to make sure it doesn’t contain syntax errors, etc. You can also use it to see whether it produces the output you expect, but even if it does not—especially if it does not—please submit it! But please don’t paste in your homework solutions.

  • Predict the output of programs written by your fellow students.

    For this part, you should not run the program in DrRacket. However, you should make a copy of the program and, after you are done with all the programs you are assigned, run each of them to compare your predicted answer against the true answer. If you don’t understand why one of them produced the answer it did, ask us privately on Piazza.

You will not be graded on your answers (we won’t even check them), but we will look at them in the aggregate (so don’t include joke or offensive answers; rickroll elsewhere).