From b3c8c2cab00da16752669cd4e8407569160b6e40 Mon Sep 17 00:00:00 2001 From: IgnBys Date: Thu, 16 Nov 2023 21:40:35 +0100 Subject: [PATCH] Added run.py files in every TaskC0* --- TaskC01/run.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ TaskC01/test.arg | 14 ++++++++++ TaskC01/test.out | 6 +++++ TaskC02/run.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ TaskC03/run.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ TaskC04/run.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ TaskC05/run.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ TaskC06/run.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 416 insertions(+) create mode 100644 TaskC01/run.py create mode 100644 TaskC01/test.arg create mode 100644 TaskC01/test.out create mode 100644 TaskC02/run.py create mode 100644 TaskC03/run.py create mode 100644 TaskC04/run.py create mode 100644 TaskC05/run.py create mode 100644 TaskC06/run.py diff --git a/TaskC01/run.py b/TaskC01/run.py new file mode 100644 index 0000000..ad82a36 --- /dev/null +++ b/TaskC01/run.py @@ -0,0 +1,66 @@ +import sys +sys.setrecursionlimit(5000) + +def write_answer(answer): + with open(output_file, 'a') as file: + file.write(answer+'\n') + +# def remove_first_symbol_from_the_list(): + +def line_checking(row, position): + help_row = row + help_position = position + next_character_array =[] + bool_value = False + for element in row: + if element=='\n': + if position in what_is_the_ended_positions(): + return True + else: + return False + next_character_array = find_next_position(help_position, element) + if next_character_array != []: + if len(next_character_array)>1: + for element_in_next_character_array in next_character_array: + if bool_value ==True: + break + else: + bool_value =line_checking(help_row[1:], element_in_next_character_array) + else: + # remove_first_symbol_from_the_list() + help_row = help_row[1:] + bool_value = line_checking(help_row, next_character_array[0]) + else: + break + return bool_value + + +def find_next_position(position, character): + with open(used_table, 'r') as readed_used_table: + take_all_possible_positions = [] + for row_used_table in readed_used_table: + line = row_used_table.strip().split(' ') + if len(line) != 1: + if position == line[0] and character == line[2]: + take_all_possible_positions.append(line[1]) + + return take_all_possible_positions +def what_is_the_ended_positions(): + array = [] + with open(used_table, 'r') as file: + for row in file: + line = row.strip().split('\t') + if len(line)==1: + array += line + return array +used_table = 'test.arg' +input_file = 'test.in' +output_file = 'test.out' +# what_is_the_ended_positions() +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: + if line_checking(row_input_file, '0')==True: + write_answer('YES') + else: + write_answer('NO') diff --git a/TaskC01/test.arg b/TaskC01/test.arg new file mode 100644 index 0000000..731d8da --- /dev/null +++ b/TaskC01/test.arg @@ -0,0 +1,14 @@ +0 0 a +0 0 c +0 1 b +1 2 b +1 3 a +1 3 c +2 3 a +2 3 c +2 2 b +3 0 a +3 0 c +3 1 b +3 +2 \ No newline at end of file diff --git a/TaskC01/test.out b/TaskC01/test.out new file mode 100644 index 0000000..fffc02c --- /dev/null +++ b/TaskC01/test.out @@ -0,0 +1,6 @@ +YES +YES +NO +NO +NO +YES diff --git a/TaskC02/run.py b/TaskC02/run.py new file mode 100644 index 0000000..ad82a36 --- /dev/null +++ b/TaskC02/run.py @@ -0,0 +1,66 @@ +import sys +sys.setrecursionlimit(5000) + +def write_answer(answer): + with open(output_file, 'a') as file: + file.write(answer+'\n') + +# def remove_first_symbol_from_the_list(): + +def line_checking(row, position): + help_row = row + help_position = position + next_character_array =[] + bool_value = False + for element in row: + if element=='\n': + if position in what_is_the_ended_positions(): + return True + else: + return False + next_character_array = find_next_position(help_position, element) + if next_character_array != []: + if len(next_character_array)>1: + for element_in_next_character_array in next_character_array: + if bool_value ==True: + break + else: + bool_value =line_checking(help_row[1:], element_in_next_character_array) + else: + # remove_first_symbol_from_the_list() + help_row = help_row[1:] + bool_value = line_checking(help_row, next_character_array[0]) + else: + break + return bool_value + + +def find_next_position(position, character): + with open(used_table, 'r') as readed_used_table: + take_all_possible_positions = [] + for row_used_table in readed_used_table: + line = row_used_table.strip().split(' ') + if len(line) != 1: + if position == line[0] and character == line[2]: + take_all_possible_positions.append(line[1]) + + return take_all_possible_positions +def what_is_the_ended_positions(): + array = [] + with open(used_table, 'r') as file: + for row in file: + line = row.strip().split('\t') + if len(line)==1: + array += line + return array +used_table = 'test.arg' +input_file = 'test.in' +output_file = 'test.out' +# what_is_the_ended_positions() +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: + if line_checking(row_input_file, '0')==True: + write_answer('YES') + else: + write_answer('NO') diff --git a/TaskC03/run.py b/TaskC03/run.py new file mode 100644 index 0000000..ad82a36 --- /dev/null +++ b/TaskC03/run.py @@ -0,0 +1,66 @@ +import sys +sys.setrecursionlimit(5000) + +def write_answer(answer): + with open(output_file, 'a') as file: + file.write(answer+'\n') + +# def remove_first_symbol_from_the_list(): + +def line_checking(row, position): + help_row = row + help_position = position + next_character_array =[] + bool_value = False + for element in row: + if element=='\n': + if position in what_is_the_ended_positions(): + return True + else: + return False + next_character_array = find_next_position(help_position, element) + if next_character_array != []: + if len(next_character_array)>1: + for element_in_next_character_array in next_character_array: + if bool_value ==True: + break + else: + bool_value =line_checking(help_row[1:], element_in_next_character_array) + else: + # remove_first_symbol_from_the_list() + help_row = help_row[1:] + bool_value = line_checking(help_row, next_character_array[0]) + else: + break + return bool_value + + +def find_next_position(position, character): + with open(used_table, 'r') as readed_used_table: + take_all_possible_positions = [] + for row_used_table in readed_used_table: + line = row_used_table.strip().split(' ') + if len(line) != 1: + if position == line[0] and character == line[2]: + take_all_possible_positions.append(line[1]) + + return take_all_possible_positions +def what_is_the_ended_positions(): + array = [] + with open(used_table, 'r') as file: + for row in file: + line = row.strip().split('\t') + if len(line)==1: + array += line + return array +used_table = 'test.arg' +input_file = 'test.in' +output_file = 'test.out' +# what_is_the_ended_positions() +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: + if line_checking(row_input_file, '0')==True: + write_answer('YES') + else: + write_answer('NO') diff --git a/TaskC04/run.py b/TaskC04/run.py new file mode 100644 index 0000000..ad82a36 --- /dev/null +++ b/TaskC04/run.py @@ -0,0 +1,66 @@ +import sys +sys.setrecursionlimit(5000) + +def write_answer(answer): + with open(output_file, 'a') as file: + file.write(answer+'\n') + +# def remove_first_symbol_from_the_list(): + +def line_checking(row, position): + help_row = row + help_position = position + next_character_array =[] + bool_value = False + for element in row: + if element=='\n': + if position in what_is_the_ended_positions(): + return True + else: + return False + next_character_array = find_next_position(help_position, element) + if next_character_array != []: + if len(next_character_array)>1: + for element_in_next_character_array in next_character_array: + if bool_value ==True: + break + else: + bool_value =line_checking(help_row[1:], element_in_next_character_array) + else: + # remove_first_symbol_from_the_list() + help_row = help_row[1:] + bool_value = line_checking(help_row, next_character_array[0]) + else: + break + return bool_value + + +def find_next_position(position, character): + with open(used_table, 'r') as readed_used_table: + take_all_possible_positions = [] + for row_used_table in readed_used_table: + line = row_used_table.strip().split(' ') + if len(line) != 1: + if position == line[0] and character == line[2]: + take_all_possible_positions.append(line[1]) + + return take_all_possible_positions +def what_is_the_ended_positions(): + array = [] + with open(used_table, 'r') as file: + for row in file: + line = row.strip().split('\t') + if len(line)==1: + array += line + return array +used_table = 'test.arg' +input_file = 'test.in' +output_file = 'test.out' +# what_is_the_ended_positions() +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: + if line_checking(row_input_file, '0')==True: + write_answer('YES') + else: + write_answer('NO') diff --git a/TaskC05/run.py b/TaskC05/run.py new file mode 100644 index 0000000..ad82a36 --- /dev/null +++ b/TaskC05/run.py @@ -0,0 +1,66 @@ +import sys +sys.setrecursionlimit(5000) + +def write_answer(answer): + with open(output_file, 'a') as file: + file.write(answer+'\n') + +# def remove_first_symbol_from_the_list(): + +def line_checking(row, position): + help_row = row + help_position = position + next_character_array =[] + bool_value = False + for element in row: + if element=='\n': + if position in what_is_the_ended_positions(): + return True + else: + return False + next_character_array = find_next_position(help_position, element) + if next_character_array != []: + if len(next_character_array)>1: + for element_in_next_character_array in next_character_array: + if bool_value ==True: + break + else: + bool_value =line_checking(help_row[1:], element_in_next_character_array) + else: + # remove_first_symbol_from_the_list() + help_row = help_row[1:] + bool_value = line_checking(help_row, next_character_array[0]) + else: + break + return bool_value + + +def find_next_position(position, character): + with open(used_table, 'r') as readed_used_table: + take_all_possible_positions = [] + for row_used_table in readed_used_table: + line = row_used_table.strip().split(' ') + if len(line) != 1: + if position == line[0] and character == line[2]: + take_all_possible_positions.append(line[1]) + + return take_all_possible_positions +def what_is_the_ended_positions(): + array = [] + with open(used_table, 'r') as file: + for row in file: + line = row.strip().split('\t') + if len(line)==1: + array += line + return array +used_table = 'test.arg' +input_file = 'test.in' +output_file = 'test.out' +# what_is_the_ended_positions() +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: + if line_checking(row_input_file, '0')==True: + write_answer('YES') + else: + write_answer('NO') diff --git a/TaskC06/run.py b/TaskC06/run.py new file mode 100644 index 0000000..ad82a36 --- /dev/null +++ b/TaskC06/run.py @@ -0,0 +1,66 @@ +import sys +sys.setrecursionlimit(5000) + +def write_answer(answer): + with open(output_file, 'a') as file: + file.write(answer+'\n') + +# def remove_first_symbol_from_the_list(): + +def line_checking(row, position): + help_row = row + help_position = position + next_character_array =[] + bool_value = False + for element in row: + if element=='\n': + if position in what_is_the_ended_positions(): + return True + else: + return False + next_character_array = find_next_position(help_position, element) + if next_character_array != []: + if len(next_character_array)>1: + for element_in_next_character_array in next_character_array: + if bool_value ==True: + break + else: + bool_value =line_checking(help_row[1:], element_in_next_character_array) + else: + # remove_first_symbol_from_the_list() + help_row = help_row[1:] + bool_value = line_checking(help_row, next_character_array[0]) + else: + break + return bool_value + + +def find_next_position(position, character): + with open(used_table, 'r') as readed_used_table: + take_all_possible_positions = [] + for row_used_table in readed_used_table: + line = row_used_table.strip().split(' ') + if len(line) != 1: + if position == line[0] and character == line[2]: + take_all_possible_positions.append(line[1]) + + return take_all_possible_positions +def what_is_the_ended_positions(): + array = [] + with open(used_table, 'r') as file: + for row in file: + line = row.strip().split('\t') + if len(line)==1: + array += line + return array +used_table = 'test.arg' +input_file = 'test.in' +output_file = 'test.out' +# what_is_the_ended_positions() +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: + if line_checking(row_input_file, '0')==True: + write_answer('YES') + else: + write_answer('NO')