# Program 1: Common Lisp

## Due Date

This assignment is due at the beginning of the lecture on Wednesday, September 24th.

## Partners

You may work with at most one other person on this assignment. If you work with a partner, please submit just one solution with both of your names on it.

## Purpose

The purpose of this assignment is to give you practice solving problems in Common Lisp.

## Sample Output

```[2]> (solve-problem '() 10 t)
There are 0 possible solutions to this problem.
NIL
[3]> (solve-problem '(1) 10 t)
(1 1 1 1 1 1 1 1 1 1)
There are 1 possible solutions to this problem.
NIL
[4]> (solve-problem '(1 2) 10 t)
(1 1 1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1 2)
(1 1 1 1 1 1 2 2)
(1 1 1 1 2 2 2)
(1 1 2 2 2 2)
(2 2 2 2 2)
There are 6 possible solutions to this problem.
NIL
[5]> (solve-problem '(1 2 3) 10 t)
(1 1 1 1 1 1 1 1 1 1)
(1 1 1 1 1 1 1 1 2)
(1 1 1 1 1 1 1 3)
(1 1 1 1 1 1 2 2)
(1 1 1 1 1 2 3)
(1 1 1 1 2 2 2)
(1 1 1 1 3 3)
(1 1 1 2 2 3)
(1 1 2 2 2 2)
(1 1 2 3 3)
(1 2 2 2 3)
(1 3 3 3)
(2 2 2 2 2)
(2 2 3 3)
There are 14 possible solutions to this problem.
NIL
[6]> (solve-problem '(1 2 3) 10)
There are 14 possible solutions to this problem.
NIL
[7]> (solve-problem '(1 2 3) 10 nil)
There are 14 possible solutions to this problem.
NIL
```

## Problem Description

Define a function named solve-problem that has two required parameters and one optional one. The first required parameter is a list consisting of one or more positive integers in ascending order. The second requirement parameter is a target value. The purpose of the function is to determine the number of unique ways that combinations of the first required parameter can be made to add up to equal the second required parameter. For example, if the first parameter is '(1 2) and the second parameter is 4, there are 3 combinations: (1 1 1 1), (1 1 2), and (2 2). Notice that (1 1 2), (1 2 1), and (2 1 1) are all considered to be the same solution!

The optional parameter may take on either the value t or nil and should default to nil. If this parameter is t, each individual solution should be printed.

If individual solutions are being printed, each individual solution should have its components printed in non-descending order. Furthermore, the solutions should be printed out in ascending lexigraphical order. Please see the sample output if you don't understand what this means.

## What to Submit

1. A printout of the source code that you produce.
2. A printout of your program running on the sample output above.