Course Level
CS1
Knowledge Unit
Fundamental Programming Concepts
Collection Item Type
Assignment
Synopsis

This assignment requires students to write regular expressions (regex) to match patterns in words that solve word puzzles. A number of the puzzles are taken from WIll Shortz' books (1996, 2003). Shortz is National Public Radio's (NPR) puzzle master. This assignment is a stand-alone exercise for practice with the powerful pattern-matching syntax of regular expressions. The assignment involves no programming. A web-based CGI compares student regex with a dictionary of words and returns a table of resulting word matches. A "starter kit" includes a series of word puzzles to encourage regex play.

The author of this material was awarded a 2016 NCWIT Engagement Excellence Award for this assignment. Learn more on NCWIT's awards page.

Recommendations

Students new to computing must reach a level of buy-in to appreciate why they should learn this new (regex) syntax. I encourage instructors to show regex in multiple contexts. For example, I show students the wildcard syntax in Microsoft Word. I like using the regexPlay .cgi (see URL provided in the assignment specification) since it focuses student attention on the regex. Some instructors may want students to (also) apply regex in the context of Python.

For more information on how to implement this assignment, see Mark's Teaching Paper, "Computing and the Digital Humanities-Computing for Poets."

Engagement Highlights

Regular expressions (regex) are a core tool in many applications, yet the syntax is terse, applications are often presented out of context, and effective and correct use of regex requires much practice. This series of word puzzles taps into a love of words and puzzles and provides an exercise with "instant gratification" of results. The applicability of regex from data processing to text mining to automata highlights the many interdisciplinary connections to computing. Student-student interactions while solving puzzles are an effective engagement practice.

Materials and Links

Materials

Computer Science Details

Programming Language
None

Material Format and Licensing Information

Creative Commons License
CC BY-NC