- #1
twoski
- 181
- 2
Homework Statement
Make a regex for the following languages on Σ = {a, b}:
(a) {w | each 'a' in w is immediately preceded and followed by 'b'}.
(b) {w | w has both 'ab' and 'ba' as sub-strings }
(c) {w ∈ {a, b} |(na(w) − nb(w)) mod 3 =/= 0}.
For c, the number of a's minus the number of b's, modulo 3, must not be 0.
The Attempt at a Solution
[/B]
a) (b*ba)(b*ba)*bb*+b*
b) (a+b)*((bab)+(aba))(a+b)*
c) (a*b*a)*+(a*b*aa)*+(a*b*b)*+(a*b*bb)*
C seems wrong and maybe i messed up B.. Any thoughts?