Outline for October 30, 2024

Reading: text, §11
Due: Homework 2, due October 30, 2023


  1. Writing a program to play rock-paper-scissors: top-down design
    1. Problem statement and general algorithm idea
    2. Data representation and program structure [rps-1.py]
    3. Figure out who wins [rps-2.py]
    4. Get computer choice [rps-3.py]
    5. Get user input [rps-4.py]
    6. Make it user-friendly [rps-5.py]

  2. Pattern matching
    1. Regular expressions
    2. Atoms: letters, digits
    3. Match any character except newline: .
    4. Match any of a set of characters: [0123456789], [^0123456789], [0-9]
    5. Repetition: *, +, {m,n}; greedy matching; put ? after and they match as few characters as possible
    6. Match start, end of string: ^, $; $ matches end of line, also
    7. Grouping: (, )
    8. Escape metacharacters: \

  3. Useful functions/methods [recomp.py, renocomp.py, regroup.py]
    1. re.compile(str) compiles the pattern into pc (that is, pc = re.compile(str))
    2. pc.match(str) returns None if compiled pattern pc does not match beginning of string str
    3. pc.search(str) returns None if pattern pc does not match any part of string str
    4. pc.findall(str) returns a list of substrings of the stringstr that match the pattern pc
    5. pc.group(str) returns the substring of the string str that the pattern pc matches
    6. pc.start(str) returns the starting position of the match
    7. pc.end(str) returns the ending position of the match
    8. pc.span(str) returns tuple (start, end) positions of match

  4. Writing a recursive permutation program [perm.py]

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 235A, Computer and Information Security
Version of October 29, 2024 at 8:21PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh