B01
This commit is contained in:
parent
ab98ed1d4c
commit
346db007f5
@ -4,9 +4,14 @@ import sys
|
||||
# global inputWords
|
||||
# global outputResult
|
||||
|
||||
fsa_description = sys.argv[1]
|
||||
inputWords = sys.argv[2]
|
||||
outputResult = sys.argv[3]
|
||||
|
||||
# fsa_description = sys.argv[1]
|
||||
# inputWords = sys.argv[2]
|
||||
# outputResult = sys.argv[3]
|
||||
|
||||
fsa_description = "fsa_description.arg"
|
||||
inputWords = "test1.in"
|
||||
outputResult = "test1.out"
|
||||
|
||||
def readDescription(currentPos, charInput):
|
||||
with open(fsa_description, 'r', encoding="utf-8") as descript:
|
||||
@ -29,11 +34,12 @@ with open(inputWords, 'r', encoding="utf-8") as inputString:
|
||||
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':
|
||||
output.write("YES\n")
|
||||
elif answersYN[i] == '0':
|
||||
output.write("NO\n")
|
||||
print(answersYN)
|
||||
# with open(outputResult, 'w', encoding="utf-8") as output:
|
||||
# for i in range(0, len(answersYN)):
|
||||
# if answersYN[i] == '1':
|
||||
# output.write("YES\n")
|
||||
# elif answersYN[i] == '0':
|
||||
# output.write("NO\n")
|
||||
|
||||
|
||||
|
9
TaskB00/test1.in
Normal file
9
TaskB00/test1.in
Normal file
@ -0,0 +1,9 @@
|
||||
xxyz
|
||||
xyz
|
||||
xy
|
||||
zz
|
||||
xxy
|
||||
yzx
|
||||
|
||||
x
|
||||
xyzz
|
13
TaskB01/fsa_description.arg
Normal file
13
TaskB01/fsa_description.arg
Normal file
@ -0,0 +1,13 @@
|
||||
0 1 0
|
||||
0 3 1
|
||||
1 2 1
|
||||
1 3 0
|
||||
2 4 1
|
||||
2 5 0
|
||||
3 3 0
|
||||
3 3 1
|
||||
4 4 1
|
||||
4 5 0
|
||||
5 5 0
|
||||
5 2 1
|
||||
2
|
39
TaskB01/run.py
Normal file
39
TaskB01/run.py
Normal file
@ -0,0 +1,39 @@
|
||||
import sys
|
||||
|
||||
fsa_description = sys.argv[1]
|
||||
inputWords = sys.argv[2]
|
||||
outputResult = sys.argv[3]
|
||||
|
||||
|
||||
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 == '2' 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\n")
|
||||
output.write("YES\n")
|
||||
elif answersYN[i] == '0':
|
||||
# print("NO\n")
|
||||
output.write("NO\n")
|
||||
|
||||
print(answersYN)
|
14
TaskB01/test.out
Normal file
14
TaskB01/test.out
Normal file
@ -0,0 +1,14 @@
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
YES
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
||||
NO
|
Loading…
Reference in New Issue
Block a user