I'm taking a computer science class and right now we need to make a regular expression for a string input consisting of the letters a, b and c with a maximum of 1 b and maximum of 4 c's.
The only operators we can use are:
ab = a and b
a|b = a or b
a+ = at least 1 a
a* = any number of a's
ϵ = empty
I came up with an expression that seems to work, but we are supposed to make the expression as short as possible and of course this is extremely long...
((b | ϵ)a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*) |
(a*(b | ϵ)(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*) |
(a*(c | ϵ)(b | ϵ)a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*) |
(a*(c | ϵ)a*(b | ϵ)(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*) |
(a*(c | ϵ)a*(c | ϵ)(b | ϵ)a*(c | ϵ)a*(c | ϵ)a*) |
(a*(c | ϵ)a*(c | ϵ)a*(b | ϵ)(c | ϵ)a*(c | ϵ)a*) |
(a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)(b | ϵ)a*(c | ϵ)a*) |
(a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*(b | ϵ)(c | ϵ)a*) |
(a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)(b | ϵ)a*) |
(a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*(c | ϵ)a*(b | ϵ))
Any tips on how to simplify this would be appreciated.