From 3ebdae72d82c50d6c9639b602abf2bd27a370d5a Mon Sep 17 00:00:00 2001 From: Jakub Pokrywka Date: Sun, 7 Nov 2021 19:44:50 +0100 Subject: [PATCH] fix --- TaskB00/run.py | 79 -------------------------------------------------- TaskB09/run.py | 79 -------------------------------------------------- 2 files changed, 158 deletions(-) delete mode 100755 TaskB00/run.py delete mode 100644 TaskB09/run.py diff --git a/TaskB00/run.py b/TaskB00/run.py deleted file mode 100755 index d1a839a..0000000 --- a/TaskB00/run.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python - -import sys - -class FSA(): - - def __init__(self,): - self.initial_state = '0' - self.final_states = set() - - self.transitions = dict() - self.alphabet = set() - - def add_transition(self, state_from, state_to, symbol): - - if state_from in self.transitions.keys(): - self.transitions[state_from][symbol] = state_to - else: - self.transitions[state_from] = dict() - self.transitions[state_from][symbol] = state_to - - def add_final_state(self, state): - self.final_states.add(state) - - - def get_final_state(self, string): - - current_state = self.initial_state - for symbol in string: - current_state = self.transitions[current_state][symbol] - return current_state - - def accepts(self,string): - - if self.get_final_state(string) in self.final_states: - return True - else: - return False - - - -fsa = FSA() -# fsa.add_transition(0, 1, 'a') -# fsa.add_transition(1, 2, 'b') -# fsa.add_transition(2, 3, 'c') -# fsa.add_final_state(3) -# fsa.add_final_state(2) -# -# print(fsa.accepts('abc')) -# print(fsa.accepts('ab')) -# print(fsa.accepts('abd')) - -table = open(sys.argv[1]) -for line in table: - line = line.rstrip('\n') - if len(line.split('\t')) == 3: - a, b, c = line.split('\t') - fsa.add_transition(a, b, c) - fsa.alphabet.add(c) - elif len(line.split('\t')) == 1: - fsa.add_final_state(line) - else: - assert False - - -for line in sys.stdin: - line = line.rstrip() - - line_n = list(line) - - for i in range(len(line_n)): - if line_n[i] not in fsa.alphabet: - line_n[i] = 'x' - - if fsa.accepts(line_n): - print('YES') - else: - print('NO') - diff --git a/TaskB09/run.py b/TaskB09/run.py deleted file mode 100644 index d1a839a..0000000 --- a/TaskB09/run.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/python - -import sys - -class FSA(): - - def __init__(self,): - self.initial_state = '0' - self.final_states = set() - - self.transitions = dict() - self.alphabet = set() - - def add_transition(self, state_from, state_to, symbol): - - if state_from in self.transitions.keys(): - self.transitions[state_from][symbol] = state_to - else: - self.transitions[state_from] = dict() - self.transitions[state_from][symbol] = state_to - - def add_final_state(self, state): - self.final_states.add(state) - - - def get_final_state(self, string): - - current_state = self.initial_state - for symbol in string: - current_state = self.transitions[current_state][symbol] - return current_state - - def accepts(self,string): - - if self.get_final_state(string) in self.final_states: - return True - else: - return False - - - -fsa = FSA() -# fsa.add_transition(0, 1, 'a') -# fsa.add_transition(1, 2, 'b') -# fsa.add_transition(2, 3, 'c') -# fsa.add_final_state(3) -# fsa.add_final_state(2) -# -# print(fsa.accepts('abc')) -# print(fsa.accepts('ab')) -# print(fsa.accepts('abd')) - -table = open(sys.argv[1]) -for line in table: - line = line.rstrip('\n') - if len(line.split('\t')) == 3: - a, b, c = line.split('\t') - fsa.add_transition(a, b, c) - fsa.alphabet.add(c) - elif len(line.split('\t')) == 1: - fsa.add_final_state(line) - else: - assert False - - -for line in sys.stdin: - line = line.rstrip() - - line_n = list(line) - - for i in range(len(line_n)): - if line_n[i] not in fsa.alphabet: - line_n[i] = 'x' - - if fsa.accepts(line_n): - print('YES') - else: - print('NO') -