From 40d837f7bc060caf6acb11f03460fb99c74a1114 Mon Sep 17 00:00:00 2001 From: Eryk Miszczuk Date: Tue, 3 Dec 2019 09:01:32 +0100 Subject: [PATCH] TaskB02 --- TaskB02/run.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TaskB02/run.py b/TaskB02/run.py index 5e73b5b..4683333 100644 --- a/TaskB02/run.py +++ b/TaskB02/run.py @@ -29,10 +29,10 @@ with open(sys.argv[1], 'r') as f: word = word.replace('\n', '') character_number = 0 # checking what is next state based on current character from word - while character_number <= len(word): - print('State: {current_state} and character: {char} on index {character_number}'.format(current_state = current_state, char = word[character_number], character_number = character_number)) + while character_number < len(word): + #print('State: {current_state} and character: {char} on index {character_number}'.format(current_state = current_state, char = word[character_number], character_number = character_number)) if ((current_state, word[character_number]) in state_move): - current_state = state_move[(current_state, word[character_number])][1] + current_state = state_move[(current_state, word[character_number])][0] character_number += 1 # if there is epsilon program move to pointed node but didnt count epsilon as character elif ((current_state, '') in state_move): @@ -40,7 +40,9 @@ with open(sys.argv[1], 'r') as f: else: current_state = -1 character_number += 1 + #print('State after {char} letter: {current_state} and index {character_number}'.format(current_state = current_state, char = word[character_number - 1], character_number = character_number)) + #print('State after consuming whole word: {current_state}'.format(current_state = current_state)) while ((current_state, '') in state_move): current_state = state_move[(current_state, '')][0]