Complete the program by specifying the regular expression

Assignment Help Theory of Computation
Reference no: EM133185395

Question: Watch the following regex video and complete the program below by specifying the regular expression on line #48 in order to define strings over {a,b,c} that start and end with the same symbol.

Note that some exemplary members and nonmembers are given as multiline strings.

Also note that line #44 denotes the empty string

Step-2: In your video tutorial, change the regular expression as you like and provide at least 5 members and 5 nonmembers and show that it works as desired

import re

members = '''aaabbca
aba
ccc
cbc
a
b
c'''

nonmembers = '''abc
ac

cccbbbbbba
aaaab'''

pattern = re.compile(r'^(a((a|b|c)*a)?|b((a|b|c)*b)?|c((a|b|c)*c)?)

, re.MULTILINE)

let us check if only the member strings are matched with the expression matches = set([x.group(0) for x in pattern.finditer(members+'\n'+nonmembers)]) print(matches == set(members.split('\n')))

Attachment:- regular expression.rar

Reference no: EM133185395

Questions Cloud

Prepare the adjusting entry necessary : Question - Flint Company had the following account balances at year-end: Cost of Goods Sold $64,950, Prepare the adjusting entry necessary
Economic development in mena region : What are the effects of oil on the political and economic development in the MENA region?
Advantages and disadvantages of e-commerce : Write papers Describe the advantages and disadvantages of e-commerce, and provide some examples of both advantage and disadvantage
What is the sales loss for BassFishing : BassFishing had its website shut down for two days due to a cyber attack. What is the sales loss for BassFishing assuming a cost of capital of 6%
Complete the program by specifying the regular expression : Regex video and complete the program below by specifying the regular expression on line #48 in order to define strings over {a,b,c} that start and end
Prepare the company abbreviated balance sheet : BBB company has $54 million of current assets and $58 million of noncurrent assets. Prepare the company abbreviated balance sheet
Interpret A Correlation Analysis : Compare the calculated and critical values to reach a conclusion for the null hypothesis. Select the test statistics and calculate its value.
What is the amount of the impairment loss : The company's management has decided to test the restaurants for possible impairment. What is the amount of the impairment loss
Identify the process you would take to set up a home budget : Identify the process you would take to set up a home budget for your specific household. Explain the specific cost categories

Reviews

Write a Review

Theory of Computation Questions & Answers

  Finite-state machine design

Create a finite-state machine design to turn your FPGA development board into a simple programmable music box.

  Redundant sequence identi cation

Redundant sequence identi cation

  Compute a shortest superstring

Dynamic programming algorithm to compute a shortest superstring.

  Propositional and predicate logic

Write down a structural induction principle for the PlayTree free type

  Design a syntactic analyzer

Design a syntactic analyzer for the language specified by the grammar

  Design unambiguous grammar to parse expressions

Write a program would read two numbers and then print all numbers between the first and the second, inclusive. Design unambiguous grammar to parse expressions

  Consider a logic function with three outputs

Consider a logic function with three outputs,  A ,  B , and  C , and three inputs,  D ,  E , and  F . The function is defined as follows:  A  is true if at least one input is true,  B  is true

  Considering a single programmed operating system

Considering a single programmed operating system, what is the minimal total time required to complete executions of the two processes? You should explain your answer with a diagram.

  How to construct an nfa

Give a construction that assumes you are given a DFA for L and show how to construct an NFA (with or without ε-moves) to recognize sort(L).

  Equivalence classes to construct minimal dfa for language

How many equivalence classes does this relation have and what are they? Use these equivalence classes to construct the minimal DFA for the language.

  Impact of moore-s law on data center costs

Discuss the impact of Moore's law on data center costs on such things as servers and communications equipment. List at least 3 steps or recommendations your data center can take to offset some or all of the effect of Moore's law.

  Problem encountered in statements in predicate logic

How the problem would be encountered in attempting to represent the following statements in Predicate logic. it should be possible to: John only likes to see French movies.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd