CPSC 3400 Assignment #4

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment

Description

5/5 - (7 votes)

P4 exercises your understanding of regular expressions and generators in Python.
Submitted programs must:
1) provide the requested functionality
2) be appropriately documented (thorough but concise)
3) use Python constructs as intended (do NOT write a C-style program)
• Use re and generators
4) be relatively robust

ALL ASSUMPTIONS SHOULD BE REASONABLE AND CLEARLY STATED
DO NOT HARD CODE

Background: Leetspeak emanates from ‘elite’ cryptic encodings of “h4X0r2”. Many online converters perform instant translation though the decoding efficacy depends on the actual correlation of alphabetic characters to 1337 characters. Conversions using Python dictionaries can be lackluster: http://stackoverflow.com/questions/33506528/translating-phrases-with-a-dictionary-in-python Common misspellings and special translations are enumerated on Wikipedia https://en.wikipedia.org/wiki/Leet and https://simple.wikipedia.org/wiki/Leet. Note that there is no formally defined and unambiguous alphabet or standards for L3375p34k: http://www.netlingo.com/word/leetspeak.php .

Setup: To be kew1, a tech summer camp wishes to email its attendees a w31c0m1n6 note that contains mostly English verbiage with 5c4773r3d 1337.

Write a Python program that, in a case-insensitive manner:
1) Extract the contents of a file, where the filename is specified on CL, with an extension
a. that is 2 or 3 characters long
b. is not ‘bat’ or ‘exe’
2) Using regular expressions, apply the following L33t translations
a. Words ending in ‘ed’ => replace ‘ed’ with ‘d’, e.g. pwned to pwnd
b. Words ending in ‘er’ => replace ‘er’ with ‘xor’, e.g. teacher to teachxor
c. Replace ‘ant’, ‘and’, ‘anned’ with ‘&’, e.g. anthill to &hill; sandpaper to s&paper
d. Replace ‘f’ with ‘ph’ in all words that start with ‘f’, e.g. famous to phamous
3) Using two different generators to systematically* insert 133t words
a. d00d, w00t, sk1llz, h4xx, n0sc0p3, pwn4g3, r0f1
4) Output the modified contents to output file n00b.txt

*use a cyclic generator to extract individual words from the list in 3a
use a numeric (forward) generator that emits integers: 10, 20, 35, 55, 80, 110, … to identify the place (based on number of words emitted) of insertion

Each submitted program will be tested on the same input file
TEST YOUR PROGRAM BEFORE SUBMISSION

Name your Python file: P4.py AND upload to Canvas