From 277d53a17b99ef2e38812f8297244878ae624453 Mon Sep 17 00:00:00 2001 From: IgnBys Date: Wed, 8 Nov 2023 19:24:38 +0100 Subject: [PATCH] TaskB03 ended --- TaskB03/fsa_description.arg | 4 ++++ TaskB03/run.py | 34 ++++++++++++++++++++++++++++++++++ TaskB03/test.out | 14 ++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 TaskB03/fsa_description.arg create mode 100644 TaskB03/run.py create mode 100644 TaskB03/test.out diff --git a/TaskB03/fsa_description.arg b/TaskB03/fsa_description.arg new file mode 100644 index 0000000..03ac6b7 --- /dev/null +++ b/TaskB03/fsa_description.arg @@ -0,0 +1,4 @@ +0 1 0 +1 1 1 +1 0 0 +0 0 1 \ No newline at end of file diff --git a/TaskB03/run.py b/TaskB03/run.py new file mode 100644 index 0000000..64320bb --- /dev/null +++ b/TaskB03/run.py @@ -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=='0': + write_answer('YES') + break + else: + write_answer('NO') + break + result, next_position = find_next_position(position,character) + if result == True: + position = next_position \ No newline at end of file diff --git a/TaskB03/test.out b/TaskB03/test.out new file mode 100644 index 0000000..9a5f7bb --- /dev/null +++ b/TaskB03/test.out @@ -0,0 +1,14 @@ +NO +NO +YES +YES +YES +NO +YES +NO +YES +NO +YES +YES +NO +YES