# Sample Modules

## ICS-33: Intermediate Programming

The following is a list of zipped Eclipse project files (more might be added during the quarter). Please feel free to download, unzip, run, and study these scripts (both their code and their run-time behavior). Programmers gain tremendous insight into all facets of programming by studying the code of other programmers (especially those with more experience; and I am happy to improve my code based on your observations -nothing is perfect). A good programmer typically makes elegant use of the required language features, resulting in smaller, more elegant code.

All downloadable projects are listed alphabetically; you can also search this page for keywords. All are zip files, so unzip them first. Most project files require the Download: standard course library which contains a variety of useful modules. If you followed the Eclipse installation instructions, you should have already created the courselib folder in your workspace and populated it with these modules.

This project contains a general solver for all backtracking search problems: problems are solved by binding aspects to values, generating every possible possibilities and determining which are solutions; one function finds a/one solution, another finds all solutions. It also contains three files that define the Problem/Aspect classes needed by the solver and scripts to solve actual problems via backtracking search.

1. Solving the N Queens problem: Can N queens be placed on an NxN chessboard so no queen can attack (horizontally, vertically or on a diagonal) any other queen. Here is a sample solution of the 4 Queens problem.
```   +---+---+---+---+
|   | Q |   |   |
+---+---+---+---+
|   |   |   | Q |
+---+---+---+---+
| Q |   |   |   |
+---+---+---+---+
|   |   | Q |   |
+---+---+---+---+```

2. Solving Sudoku puzzles: Can a 9x9 square (read from a file) have its empty entries filled so that every row and column contains the numbers all the numbers 1-9, and 3x3 squares comprising the 9x9 cube likewise each contain all the numbers 1-9. Here is a sample problem (on the left) and solution (on the right).
```   9 6   | 1   4 |   5                      9 6 3 | 1 7 4 | 2 5 8
8 | 3     | 6                        1 7 8 | 3 2 5 | 6 4 9
2     |       |     1                    2 5 4 | 6 8 9 | 7 3 1
-------+-------+------                   -------+-------+------
8     | 4   7 |     6                    8 2 1 | 4 3 7 | 5 9 6
6 |       | 3                        4 9 6 | 8 5 2 | 3 1 7
7     | 9   1 |     4                    7 3 5 | 9 6 1 | 8 2 4
-------+-------+------                   -------+-------+------
5     |       |     2                    5 8 9 | 7 1 3 | 4 6 2
7 | 2   6 | 9                        3 1 7 | 2 4 6 | 9 8 5
4   | 5   8 |   7                      6 4 2 | 5 9 8 | 1 7 3```

3. Solving Anagrams: For any input of words, find all sequences of words (of a certain or arbitrary length, each rom some dictionary of legal words) that contain exactly those characters (including repetitions). For example, the word California has an anagram racial info.