Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here's a Christmas Eve brain teaser.

FA state to regular expression by the state removal method

Generating regular expression from Finite Automata - GeeksforGeeks[^]

Using the first method at that link.

abcd(ef)*g

q0:
        abcd -> q1

q1:
        ef -> q1
        g -> q2

*q2:


The idea here is to turn the above qX set of states back into a regular expression that is equivalent to the one at the top.

You can see I've already done some of it. the string "abcd" was originally several states/transitions, and "ef" was two.

The main trouble is states like q1 where there is more than one transition. I think I can handle loops (maybe?) but right now this part is getting me.

What I have tried:

GitHub - codewitch-honey-crisis/FAToRegex: A testbed for FA to Regex via state removal in C# (work in progress)[^]

See Program.cs for the meat. The rest is just support. The function of interest is ToRegex().
Posted
Updated 29-Dec-21 13:59pm
Comments
OriginalGriff 24-Dec-21 11:38am    
Bloody students, posting their homework ... :D
Maciej Los 29-Dec-21 15:56pm    
:D

1 solution

I figured it out. Solution is at the link.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900