2022 September 19,

CS 254: Day 04

Carleton College, Joshua R. Davis

Today's homework is entirely Python programming. You solve four problems about DFAs and NFAs and three problems about regular expressions.

DFAs and NFAs

Download the file dfaNFA.py. Read it in detail. It consists of four sections: sets, DFAs, NFAs, and main. There are five unimplemented functions.

A. Implement dfaAccepts and dfaZerosDivisibleByTwo. Once you are done, run the program. The first two tests in main should work.

B. Implement dfaIntersection. Then the third test in main should work.

C. Implement nfaAccepts. Then the fourth test should work.

D. Implement dfaFromNFA. Be careful about ordering issues. Then the fifth test should work.

Regular Expressions

Read the Python regular expression tutorial on our course web site. Download regExp.py.

E. Fill in the variable miscapitalized based on the specification just before it. Then the first test in main should work.

F. Fill in the variable email based on the specification. Then the next couple of tests should work.

G. Implement the function fixDates based on the specification. Then the last tests should work.

Submit Your Work Electronically

In both files, feel free to add your own tests, if they help you debug. Like the tests already in main, they should run if a user runs the file, but they should not run if a user imports the file.

When you are finished, mount the COURSES file server and place your two files in your CS 254 hand-in folder there.