CS4811: Homework 3 --- Uninformed Search


Due: Wednesday, February 8, 2006, beginning of class. (Assigned: Wednesday, January 25, 2005.)

Reminder: This is an individual assignment. All the work should be the author's and in accordance with the university's academic integrity policies. You are allowed to use any source in preparing your answers, but if you use any other source than the current textbook and the current class notes, you should clearly specify it on your assignment.

Problem: In this assignment, you will implement a system that solves cryptarithmetic problems using uninformed search. You will turn in both the solver and a detailed report. Cryptarithmetic problems are puzzles like the following:
  
             S E N D
             M O R E
          +----------
           M O N E Y
A solution to the puzzle is an assignment of a single digit to each symbol. The assignment should satisfy the arithmetic operation. For instance, a solution to the above problem is
 
             9 5 6 7
             1 0 8 5
          +----------
           1 0 6 5 2
Other puzzle rules are:
Task:
  1. Show how to formulate a cryptarithmetic puzzle as a search problem. Clearly show the search space, the operators, the start state and the goal state. Show a little portion of a search graph to illustrate your formulation.
  2. Implement the depth-first search (DFS), or the breadth-first search (BFS) algorithm as described in the textbook. If you implement and experiment with both, you get 5 extra credits. Then, implement a cryptarithmetic puzzle solver that uses uninformed search. The input to the solver should be a cryptarithmetic problem. You may decide how the input should be given. One way could be to use a list form:
       (+ (S E N D) (M O R E) (M O N E Y) )
    
    You may choose any programming language that runs on the department Unix platforms. If you implement your program on a nondepartmental machine make sure to transport and check it well ahead of the due date. If you plan to use a language other than Lisp/Scheme, C++, or Java check with me first.

    Note that if your program generates assignments systematically, the part of the search algorithm that checks for nodes already in CLOSED is not necessary. This makes the CLOSED list unnecessary and saves a *significant* amount of memory. You may choose to use or eliminate the CLOSED list. If you experiment with and without CLOSED, you get 5 extra credits.

    Test your program first with simple puzzles like

      (+ (A) (B) (C))
      (* (A) (B) (C))
      (+ (A B) (C D) (E F))
    
    and then with
       (+ (S E N D) (M O R E) (M O N E Y) )
    
    and then with two more examples that you choose.

    You may limit the program to two operands and to only addition and multiplication.

  3. Turn in your program and a report. Both a hardcopy and an online submit is required. For program printouts the use of enscript with double columns saves a lot of paper
     enscript -2Gr -pMyProg.ps MyProg 
    The above command prints MyProg in 2 columns landscape format and leaves the output in MyProg.ps. Please check your output for wrapped lines and format accordingly. See the manual pages for enscript for more options. For your report use a format that can be opened on the department machines: StarOffice, pdf, or postscript.
Additional notes:
  1. You report should minimally include the following:
    1. The commands or makefiles to build your program.
    2. The commands used to run your program and an example of the output to be expected. Include one department machine name you tested your program on.
    3. Your formulation of the search problem as described above (show the 4 components and an example graph).
    4. Your choice of the search technique(s) with reasons.
    5. Whether your program stops at the first solution or goes ahead to find all the possible solutions.
    6. Results of your experimental runs. Include the CPU time needed to solve each problem, and comment on your results.
    7. It is important to implement your program as close as possible to the pseudocode of BFS/DFS. Fully comment your program and provide an overview in the report.
    8. Please do not turn in lengthy search traces, they are unreadable and waste paper.
  2. Below are two other examples. Of course, several others are available on the web.
                   E A T        8 1 9           P O T A T O     1 6 8 4 8 6
                 T H A T      9 2 1 9           T O M A T O     8 6 3 4 8 6
              +----------  +---------        +-------------  +-------------
               A P P L E    1 0 0 3 8         P U M P K I N   1 0 3 1 9 7 2
    
  3. You might find cryptarithmetic solvers on the web. If you consult any such solver, you should state the URL and to what extent you used it.