Compare commits

...

2 Commits

Author SHA1 Message Date
doasdsk
7949d39131 B08 2023-11-10 23:26:27 +01:00
doasdsk
e8324961be B08 2023-11-10 23:26:10 +01:00
3 changed files with 238 additions and 0 deletions

190
TaskB08/fsa_description.arg Normal file
View File

@ -0,0 +1,190 @@
0 1 j
1 2 u
2 3 l
3 4 i
4 5 e
5 6 t
0 0 a
0 0 b
0 0 c
0 0 d
0 0 e
0 0 f
0 0 g
0 0 h
0 0 i
0 0 k
0 0 l
0 0 m
0 0 n
0 0 o
0 0 p
0 0 q
0 0 r
0 0 s
0 0 t
0 0 u
0 0 v
0 0 w
0 0 x
0 0 y
0 0 z
0 0
1 0 a
1 0 b
1 0 c
1 0 d
1 0 e
1 0 f
1 0 g
1 0 h
1 0 i
1 0 j
1 0 k
1 0 l
1 0 m
1 0 n
1 0 o
1 0 p
1 0 q
1 0 r
1 0 s
1 0 t
1 0 v
1 0 w
1 0 x
1 0 y
1 0 z
1 0
2 0 a
2 0 b
2 0 c
2 0 d
2 0 e
2 0 f
2 0 g
2 0 h
2 0 i
2 0 j
2 0 k
2 0 m
2 0 n
2 0 o
2 0 p
2 0 q
2 0 r
2 0 s
2 0 t
2 0 u
2 0 v
2 0 w
2 0 x
2 0 y
2 0 z
2 0
3 0 a
3 0 b
3 0 c
3 0 d
3 0 e
3 0 f
3 0 g
3 0 h
3 0 j
3 0 k
3 0 l
3 0 m
3 0 n
3 0 o
3 0 p
3 0 q
3 0 r
3 0 s
3 0 t
3 0 u
3 0 v
3 0 w
3 0 x
3 0 y
3 0 z
3 0
4 0 a
4 0 b
4 0 c
4 0 d
4 0 f
4 0 g
4 0 h
4 0 i
4 0 j
4 0 k
4 0 l
4 0 m
4 0 n
4 0 o
4 0 p
4 0 q
4 0 r
4 0 s
4 0 t
4 0 u
4 0 v
4 0 w
4 0 x
4 0 y
4 0 z
4 0
5 0 a
5 0 b
5 0 c
5 0 d
5 0 e
5 0 f
5 0 g
5 0 h
5 0 i
5 0 j
5 0 k
5 0 l
5 0 m
5 0 n
5 0 o
5 0 p
5 0 q
5 0 r
5 0 s
5 0 u
5 0 v
5 0 w
5 0 x
5 0 y
5 0 z
5 0
6 6 a
6 6 b
6 6 c
6 6 d
6 6 e
6 6 f
6 6 g
6 6 h
6 6 i
6 6 j
6 6 k
6 6 l
6 6 m
6 6 n
6 6 o
6 6 p
6 6 q
6 6 r
6 6 s
6 6 t
6 6 u
6 6 v
6 6 w
6 6 x
6 6 y
6 6 z
6 6
6

45
TaskB08/run.py Normal file
View File

@ -0,0 +1,45 @@
import sys
fsa_description = sys.argv[1]
inputWords = sys.argv[2]
outputResult = sys.argv[3]
# fsa_description = "fsa_description.arg"
# inputWords = "simple.in"
# outputResult = "simple.out"
def readDescription(currentPos, charInput):
with open(fsa_description, 'r', encoding="utf-8") as descript:
for line in descript:
if len(line.strip().split(' ')) == 1:
return line[0], 0
transition = line.strip().split(' ')
if len(transition)==2:
transition.append(' ')
if len(transition) == 3 and currentPos == transition[0] and charInput == transition[2]:
return transition[1], 1
return None, None
answersYN = ''
with open(inputWords, 'r', encoding="utf-8") as inputString:
for line in inputString:
pos = '0'
for char in line:
if char == '\n':
answersYN += ('1' if pos == '6' else '0')
break
newPos, flag = readDescription(pos, char)
if flag == 1:
pos = newPos
with open(outputResult, 'w', encoding="utf-8") as output:
for i in range(0, len(answersYN)):
if answersYN[i] == '1':
# print("YES")
output.write("YES\n")
elif answersYN[i] == '0':
# print("NO")
output.write("NO\n")
print(answersYN)

3
TaskB08/simple.out Normal file
View File

@ -0,0 +1,3 @@
NO
YES
YES