-2

I am lost on this and we a restricted to using flex/lex regular expression. I can easily do this with a lookahead predicate but i'm not allowed to use those. The does not end in (0) part is simple enough to do, it the other part(must contain at least one (0), one (1) and one (2) is stumping me. Any help would be greatly appreciated.

Klint
  • 5
  • 1

1 Answers1

1

Here is an expression for all strings which contain both 0 and 1: $$ \Sigma^*0\Sigma^*1\Sigma^* + \Sigma^*1\Sigma^*0\Sigma^*. $$ If we also insist that the string not end in 0, we can modify the expression as follows: $$ \Sigma^*0\Sigma^*1. $$ I'll leave you the generalization to your particular case.

Yuval Filmus
  • 276,994
  • 27
  • 311
  • 503