#+TITLE: Assignment Three #+AUTHOR: Logan Hunt #+STARTUP: entitiespretty fold inlineimages #+LATEX_HEADER: \notindent \notga \usepackage{ dsfont } \usepackage{amsmath} #+LATEX: \setlength\parindent{0pt} #+OPTIONS: toc:nil * Question One \begin{verbatim} <(> <)> <{> <(> > <)> \\ <}> \end{verbatim} * Question Two #+attr_latex: :width 250px [[./2.png]] The first buffer is filled twice. The second is filled once, and the last contains three elements. * Question Three Strings starting and ending with "x" with any number of x or y's in between. * Question Four ** a \begin{verbatim} col(o|ou)r \end{verbatim} ** b \begin{verbatim} m(o|u)m \end{verbatim} ** c \begin{verbatim} analy(z|s)e \end{verbatim} * Question Five ** a 1. bbbaa 2. bbbcc 3. bbbac 4. bbbca ** b 1. bbb 2. aa 3. cc 4. ac 5. ca ** c 1. bbb 2. acac ** d 1. bbbacac * Question Six ** a \begin{verbatim} In [1]: ["aggie"[0:n] for n in range(0, len("aggie")+1)] Out[1]: ['', 'a', 'ag', 'agg', 'aggi', 'aggie'] \end{verbatim} ** b \begin{verbatim} In [3]: ["aggie"[n:len("aggie")] for n in range(0, len("aggie")+1)] Out[3]: ['aggie', 'ggie', 'gie', 'ie', 'e', ''] \end{verbatim} ** c \begin{verbatim} In [4]: ["aggie"[0:n] for n in range(1, len("aggie"))] Out[4]: ['a', 'ag', 'agg', 'aggi'] \end{verbatim} ** d \begin{verbatim} In [8]: def subs(s): ...: proper_substrings = set() ...: for i in range(len(s)+1): ...: for j in range(len(s)+1): ...: if (i <= j): ...: sub = s[i:j] ...: if (sub != "" and sub != s): ...: proper_substrings.add(sub) ...: return proper_substrings ...: In [9]: subs("aggie") Out[9]: {'a', 'ag', 'agg', 'aggi', 'e', 'g', 'gg', 'ggi', 'ggie', 'gi', 'gie', 'i', 'ie'} \end{verbatim} * Question Seven \begin{verbatim} (u|U)(n|N)(i|I)(o|O)(n|N) \end{verbatim} * Question Eight $\textdollar([0-9]|[0-9]^2|[0-9]^3)(,[0-9]^3)^*.[0-9][0-9]$ * Question Nine nonzeroDigit \Rightarrow 1|2|3|4|5|6|7|8|9|A|B|C|D|E|F hex \Rightarrow nonzeroDigit^{+}(0|nonzeroDigit)^{*} * Question Ten ** a \begin{verbatim} (0011)*|(1100)* \end{verbatim} ** b [[./10b.png]] \begin{verbatim} ((00)|(0(11)*0?))|((11)|(1(00)*1?)) \end{verbatim} ** c \begin{verbatim} a?b?c?d? \end{verbatim} * Question Eleven ** a \begin{verbatim} (\t| )+ \end{verbatim} ** b \begin{verbatim} (/\*)[^(*/)]*(\*/) \end{verbatim} ** c \begin{verbatim} "[^"]*" \end{verbatim} * Question Twelve nonVowelPart \Rightarrow [\textasciicircum aeiou]^{*} aPart \Rightarrow a^{+}[\textasciicircum eiou]^{*} ePart \Rightarrow e^{+}[\textasciicircum aiou]^{*} iPart \Rightarrow i^{+}[\textasciicircum aeou]^{*} oPart \Rightarrow o^{+}[\textasciicircum aeiu]^{*} uPart \Rightarrow u^{+} [\textasciicircum aeio]^{*} str \Rightarrow (nonVowelPart)(aPart)(ePart)(iPart)(oPart)(uPart)