Re: help with regular expressions (Torben Ęgidius Mogensen)
12 Oct 2004 00:55:43 -0400

          From comp.compilers

Related articles
help with regular expressions (keith) (2004-10-09)
Re: help with regular expressions (Carl Cerecke) (2004-10-12)
Re: help with regular expressions (Gene Wirchenko) (2004-10-12)
Re: help with regular expressions (Jeremy Wright) (2004-10-12)
Re: help with regular expressions (2004-10-12)
| List of all articles for this month |

From: (Torben Ęgidius Mogensen)
Newsgroups: comp.compilers
Date: 12 Oct 2004 00:55:43 -0400
Organization: Department of Computer Science, University of Copenhagen
References: 04-10-077
Keywords: lex
Posted-Date: 12 Oct 2004 00:55:43 EDT

keith <> writes:

> write the regular expression for strings over the alphabet {a,b,c}
> that don't contain the contiguous substring baa. I've come up with
> this:
> (a|c|(ba(b|c))|bb|bc)*
> ??? Is this correct?

No, the strings "bbaa" and "babaa" are in the language you describe.

> binary numbers n such that there exists an integer solution of an+bn=cn,
> don't know what to do about this one :-( As far as I am concerned all
> binary numbers satisfy this condition as integer+*integer=integer.

The exercise says a^n+b^n=c^n, for which Fermats theorem says that
there exist integer solutions only when 0<=n<=2.


[I have an elegant regular expression that solves the problem, but
the margin of this message is too small to contain it.

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.