From c78c8da1e008658543819fdfdae514b53f20c623 Mon Sep 17 00:00:00 2001 From: deadsmond <01.lewicki@gmail.com> Date: Mon, 25 Nov 2019 19:10:41 +0100 Subject: [PATCH] 'hm' --- TaskB01/run | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/TaskB01/run b/TaskB01/run index ada0cda..3216646 100644 --- a/TaskB01/run +++ b/TaskB01/run @@ -35,21 +35,22 @@ class automata: def test_string(self, text): self.state = ['0'] text = text.replace('\n', '') + # for all values in text for i in text: + # for all actual states for q in self.state: - self.state = self.get_node_transition(q, i) + # move state to its transition + q = self.get_node_transition(q, i) if not self.state: return False return self.check_if_accepted() + # check if there is common part between states of automata and accepting states def check_if_accepted(self): return not set(self.state).isdisjoint(self.accepting_states) def get_node_transition(self, q, i): - self.storage[q] - if i[0] == query: - return i[1] - return [] + return [] if not self.storage[q][i] else return self.storage[q][i] auto = automata()