CSC150 — Assignments

Assignment 4

Due: Wed 7 Dec.

You may use one grace day on one of assignments 2, 3 and 4, handing one of them in up to 24 hours past the due time.

You may work in pairs (and submit one version) for this assignment.

Part I: 3D Math

Complete A4.math.rkt. Most of these are one-liners; visible-segment, visible-triangle and triangulate average a half dozen lines.

Part II: 3D Drawing

Complete A4.view.rkt. Here's the spinning room from lecture as a small test.

Assignment 3

You may use one grace day on one of assignments 2, 3 and 4, handing one of them in up to 24 hours past the due time.

You may work in pairs (and submit one version) for this assignment.

Part I: Maze Solving Algorithm

Complete A3.maze-route.rkt.

Part II: Maze Input and Output

Complete A3.maze-format.rkt.

Some mazes to try from CSC148. The intended start and end are labelled 1 and 2: a good exercise is to write a function to find a particular value in a grid. To read a file as a list of strings:

  (require 2htdp/batch-io)
  (read-lines «file-name-string»)

It can be fun calling grid→image on avoid for debugging, and mazes annotated with routes [exercise: (show-route maze a-route)]. If you make a list of images [maybe avoid at each step, or parts of a route], you can make a movie from:

(require 2htdp/universe)
(run-movie «images-per-second» «list-of-images»)

Part III: 3D Maze Route Animation

Left for Assignment 4.

Assignment 2

You may use one grace day on one of assignments 2, 3 and 4, handing one of them in up to 24 hours past the due time.

You may work in pairs (and submit one version) for this assignment.

There are two parts.

Part I: Digital Sound Processing

Follow these instructions.

Part II: Web Crawl

Complete this..

Assignment 1

Write the functions described in the comments of this Racket file.

Commentary, two solutions, and a review exercise for random-ae. Discussion of solution for value. One complete solution to A1 part I, but be sure to look at all three files.

When we do structures soon, we'll cover and use pattern matching. You might enjoy trying and using it already, for lists. Some examples to get you started:

#lang racket

#| 'match' is a special form (not function). The syntax is: |#
#;
(match <exp>
  [<pattern> <result-exp>]
  ...)
#| Semantics:
     Evalute <exp>.
     Match the value to first <pattern> whose form could create the value.
       A <pattern> is built *syntactically* from:
         literals
         (new) variable names
         constructor "calls" on patterns: (<constructor> <sub-pattern> ...)
       It matches if the variables could be given values so that if the
        <pattern> would be evaluated as an expression it would produce the
        value of <exp>. |#

(match (+ 1 1) [2 "yes"])
(match (list 1 'a "b") [(list x y z) (list z y x)])
(match (list 1 'a "b") [(cons f r) (list f r)])
(match '((a) (bc) (d e) (f g))
  [(cons (list a b) ps) b]
  [(cons (list 'b) ps) ps]
  [(cons (list b) ps) b])