This commit is contained in:
doasdsk 2023-11-10 22:03:34 +01:00
parent 386edf797c
commit 52194be853
3 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,45 @@
0 1 1
0 0 0
0 0 2
0 0 3
0 0 4
0 0 5
0 0 6
0 0 7
0 0 8
0 0 9
0 0 x
1 1 1
1 2 9
1 0 0
1 0 2
1 0 3
1 0 4
1 0 5
1 0 6
1 0 7
1 0 8
1 0 x
2 3 0
2 3 1
2 3 2
2 3 3
2 3 4
2 3 5
2 3 6
2 3 7
2 3 8
2 3 9
2 0 x
3 4 0
3 4 1
3 4 2
3 4 3
3 4 4
3 4 5
3 4 6
3 4 7
3 4 8
3 4 9
3 0 x
4

43
TaskB05/run.py Normal file
View File

@ -0,0 +1,43 @@
import sys
fsa_description = sys.argv[1]
inputWords = sys.argv[2]
outputResult = sys.argv[3]
# fsa_description = "fsa_description.arg"
# inputWords = "test.in"
# outputResult = "test.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) == 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 == '4' 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)

6
TaskB05/simple.out Normal file
View File

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