AI Fall 2009

  1. Course webpage
  2. Syllabus
  3. Python.org, Python tutorial (Guido van Rossum), Beginner's Guide, more documentation from the Python site
  4. Unit 1 Word ladders
    1. Three letter words dictionary to demo depth first and breadth first
      Three letter words with a loop

    2. Preliminary program steps for Lab 1 - construct a "word ladder" consisting of all the words 1 letter different from a given word:
      1. Assignment for Lab 1:
        • Assignment (.doc)
        • Write functions read_words, countDiff, printLadder, main
        • Complete the pdf Lab 1
      2. words.txt and wordsShort.txt - many of these alternate versions use this shortened word dictionary
      3. spell.py programs from the our website
        1. spell_0.py, sample output
          understand what this syntax is doing: wlist=open('words.txt').read().split('\n')[:-1]
          Or alternate spell_0.py with traditional syntax
        2. spell_1.py
          understand the syntax for reading from a file, and how to use a for loop in Python
        3. spell_1B.py
          how to use a while loop that stops when an item is found, using a boolean variable
          Or alternate spell_1.py with alternate syntax reading the file line by line, adding each new word into the wordlist.
        4. spell_2.py
          defining a function in Python, using break to exit a while loop. Print the position in the dictionary of the located word
          Or alternate spell_2.py with boolean variable "found"
        5. spell_3.py
          Using a while-else loop, more about while-else
        6. spell_4.py
      4. Steps to take in solving Lab01, the neighbors lab
        1. nbrs00.out
          Using a shortened dictionary file, keep asking for more words to try until *quit* is entered
        2. nbrs_0Prelim1.out
          Enter a second string to match a given word, for example "abated". Count the number of characters different.
        3. nbrs_0Prelim2.out
          Enter a word, go through the entire short dictionary and count the characters different for each other word.
        4. nbrs_0Prelim3.out
          Enter a second string to match a given word, for example "abated". Count the number of characters different. Print "NEIGHBOR" each time a neighbor is found. Add each NEIGHBOR to a neighborlist. Print this final neighborlist.
        5. nbrs.out
          Enter words from the dictionary, print the neighborlist for each.
    3. freq.py programs:
      1. freq_0.py: study Python "zip" function, used to construct a list of tuples for each character in a string
        lowercase="abcdefg"
        ziplist=zip(lowercase,[0,0,0,0,0,0,0,0,0,0]) # or zip(lowercase,[0]*10)
        # ziplist <- [('a', 0), ('b', 0), ('c', 0), ('d', 0), ('e', 0), ('f', 0), ('g', 0), ('h', 0), ('i', 0), ('j', 0)]
        dictionary=dict(ziplist) # construct a "dictionary" or "hash table"
        # dictionary <- {'a': 0, 'c': 0, 'b': 0, 'e': 0, 'd': 0, 'g': 0, 'f': 0, 'i': 0, 'h': 0, 'j': 0}
      2. Or alternate freq_0.py version with traditional syntax, not using "zip" and "dict" functions, using more traditional syntax for file reading and constructing the dictionary
      3. Alternate freq_1.py with traditional syntax

    4. Preliminary program steps for Lab 2 - constructing a word ladder of 6-letter words (each new word changes by one letter) in which the first and last word differ by 6
      1. Lab 2 step 1 - Choose a random word from the list, make a list of all the words in the word list that are 1 letter different from the original word
      2. Lab 2 step 2 - Choose a random word from the list. Make a list of neighbors that consist of the words in wordlist that are 1 letter different from the previous word in this list. This version iterates through this process 5 times, each iteration finding a word 1 letter different from the current word.
      3. Lab 2 step 3 Choose a random word from the wordlist. Make a list of neighbors that consist of the words in wordlist that are 1 letter different from the previous word in the ladder. Continue this process extending the neighborlist through different words and their corresponding nbr lists. Continue until either:
        1. You reach a DEAD END with no new words to extend
        2. The length of the current neighbor list becomes greater than a certain amount, such as length 20
        3. The difference between the first and last words in the neighborlist is 6
    5. Assignment (.doc) for Lab 02
    6. Lab 2 writeup (pdf) - constructing a word ladder of 6-letter words (each new word changes by one letter) in which the first and last word differ by 6

  • Lisp programming and sample tutorial