-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDFA0.py
More file actions
56 lines (42 loc) · 1.05 KB
/
Copy pathDFA0.py
File metadata and controls
56 lines (42 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
states = [0,1,2,3]
currentState = states[0]
currentindex =0
str = input("enter your string to pass \n")
print(len(str) )
a =[str[i:i+4] for i in range(0, len(str), 4)]
print(a)
for i in range(len(a)):
print(i)
if(len(a[i])>0):
if (a[i][0] =='a' ):
currentState =(states[1])
if (a[i][0]=='b'):
currentState=(states[0])
else:
break
if(len(a[i])>1):
if (a[i][1]=='a'):
currentState=(states[1])
if (a[i][1]=='b'):
currentState=(states[2])
else:
break
if(len(a[i])>2):
if (a[i][2]=='a'):
currentState=(states[1])
if (a[i][2]=='b'):
currentState=(states[3])
else:
break
if(len(a[i])>3):
if (a[i][3]=='a'):
currentState=(states[1])
if (a[i][3]=='b'):
currentState=(states[0])
else:
break
if currentState == 3:
print('success')
else:
print('failed')
print(currentState)