-1

Language of odd length and cannot contain length multiple of 3 over ={,}

1 Answers1

1

OK to have an odd length that's not a multiple of 3, we can have a "head" part that generates strings of length 6n, and then a "tail" part that generates strings of length 1 and 5 (but not 7). Any odd number that's not a multiple of 3 can be written as 6n + 1 or 6n + 5 for n >= 0. So, let's get crackin.

r = ((a + b)^6)*((a + b) + (a + b)^5)

I have used a shorthand notation here which you can omit; basically, s ^ n stands for the regular expression s repeated n times. As long as n is a definite number this can be written out, just makes the regular expression a little longer.

Patrick87
  • 27,682
  • 3
  • 38
  • 73