# Exam Prep 7: Scheme

Students from past semesters wanted more content and structured time to prepare for exams. Exam Prep sections are a way to solidify your understanding of the week's materials. The problems are typically designed to be a bridge between discussion/lab/homework difficulty and exam difficulty.

**Reminder:** There is nothing to turn in and there is no credit given for attending Exam Prep Sections.

We try to make these problems **exam level** , so you are not expected to be able to solve them coming straight from lecture without additional practice.
To get the most out of Exam Prep, we recommend you **try these problems first on your own** before coming to the Exam Prep section, where we will explain how to solve these problems while giving tips and advice for the exam. Do not worry if you struggle with these problems, **it is okay to struggle while learning**.

You can work with anyone you want, including sharing solutions. We just ask you don't spoil the problems for anyone else in the class. Thanks!

You may only put code where there are underscores for the codewriting questions.

You can test your functions on their doctests by clicking the red test tube in the top right corner after clicking Run in 61A Code. Passing the doctests is not necessarily enough to get the problem fully correct. You must fully solve the stated problem.

### Q1: Slice It!

**Difficulty: ⭐⭐**

Implement the `get-slicer`

procedure, which takes integers `a`

and `b`

and returns an *a-b slicing function*. An `a-b`

slicing function takes in a list as input and outputs a new list with the values of the original list from index `a`

(inclusive) to index `b`

(exclusive).

Your implementation should behave like Python slicing, but should assume a step size of one with no negative slicing indices. Indices start at zero.

**Note:** the skeleton code is just a suggestion. Feel free to use your own structure if you prefer.

### Q2: Partition Options

**Difficulty: ⭐⭐**

First, write the procedure `combine`

, which takes in lists `lst1`

and `lst2`

, as well as a value `x`

, and outputs a new list with `x`

before each item of `lst1`

, and then all elements of `lst2`

unmodified. For examples, see the doctests.

Then write the procedure `partition-options`

, which takes in positive integers `total`

and `biggest`

and outputs a list of lists, in which each inner list contains numbers no larger than `biggest`

that sum to `total`

.

**Note:** The skeleton code is just a suggestion; feel free to use your own structure if you prefer.

### Q3: Find It!

**Difficulty: ⭐⭐**

Implement the `find-in-tree`

procedure, which takes a Scheme tree `t`

, a target value `goal`

and returns a list containing the node values on a path from the root of `t`

to a node containing `goal`

. If no such path exists, `find-in-tree`

returns an empty list.

Complete `find-in-branches`

for ease of implementation. `find-in-branches`

takes a list of branches `bs`

and a value `goal`

and returns a list containing the node values on a path from any branch to a node containing `goal`

. If no such path exists, `find-in-branches`

returns an empty list.

The Scheme tree ADT is specified at the top of the skeleton code.

**Note:** The skeleton code is just a suggestion; feel free to use your own structure if you prefer.