TaskB01 ended

This commit is contained in:
IgnBys 2023-11-08 18:48:12 +01:00
parent 5e460ef202
commit ee6e76bf2e
6 changed files with 67 additions and 12 deletions

View File

@ -8,9 +8,13 @@ def find_next_position(position, character):
line = row_used_table.strip().split('\t') line = row_used_table.strip().split('\t')
if position == line[0] and character == line[2]: if position == line[0] and character == line[2]:
return True,line[1] return True,line[1]
used_table = sys.argv[1]
input_file = sys.argv[2] used_table = 'fsa_description.arg'
output_file = sys.argv[3] input_file = 'test1.in'
output_file = 'test1.out'
# used_table = sys.argv[1]
# input_file = sys.argv[2]
# output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file: with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file: with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file: for row_input_file in readed_input_file:

0
TaskB00/test.out Normal file
View File

View File

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

View File

@ -0,0 +1,12 @@
0 1 0
0 3 1
3 3 0
3 3 1
1 3 0
1 2 1
2 4 1
4 4 1
4 5 0
5 5 0
2 5 0
5 2 1

34
TaskB01/run.py Normal file
View File

@ -0,0 +1,34 @@
import sys
def write_answer(answer):
with open(output_file, 'a') as file:
file.write(answer+'\n')
def find_next_position(position, character):
with open(used_table, 'r') as readed_used_table:
for row_used_table in readed_used_table:
line = row_used_table.strip().split(' ')
if position == line[0] and character == line[2]:
return True,line[1]
used_table = 'fsa_description.arg'
input_file = 'test.in'
output_file = 'test.out'
# used_table = sys.argv[1]
# input_file = sys.argv[2]
# output_file = sys.argv[3]
with open(output_file, 'w') as readed_output_file:
with open(input_file, 'r') as readed_input_file:
for row_input_file in readed_input_file:
result = False
next_position = None
position = '0'
for character in row_input_file:
if character =='\n':
if position=='2':
write_answer('YES')
break
else:
write_answer('NO')
break
result, next_position = find_next_position(position,character)
if result == True:
position = next_position

14
TaskB01/test.out Normal file
View File

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