2019-10-04

Directions: You may not consult any sources, including your old homework.

Bonus +5% if all functions have at least one (nontrivial) associated test case. Functions that are not complete but have three tests that outline an approach to creating the function will receive half credit.

  1. (some13) Inputs: two numbers n, c. Output a list of the first c numbers after n that leave a remainder of 2 when divided by 13. Skip multiples of five, if there are any.

  2. (collatz1) Given a list of numbers, change every odd number $n$ to $3n+1$ and change every even number $n$ to $n/2$. Put out a list.

  3. (word-table): Given a list of symbols, create a list of pairs (list symbol count) showing how many times each symbol appears in the list. The pairs may appear in any order in the result.

     (word-table '(dog cat elephant dog dog mouse mouse))
     => '((dog 3) (cat 1) (elephant 1) (mouse 2))
    
  4. (live-ants) Given a two lists of points in the plane, poison and ants. Return a list of all of the ants that are at least distance 5 from every point in the poison list.

Stuck in the Mud

These are the rules for the dice game Stuck in the Mud:

You are going to write a simulator for stuck in the mud.

Starter Code

(ql:quickload :lisp-unit)
(use-package :lisp-unit)
(setf *print-failures* t)

(defun dist (x1 y1 x2 y2)
  (sqrt (+ (expt (- x1 x2) 2)
           (expt (- y1 y2) 2))))