diff --git a/TaskB02/run.py b/TaskB02/run.py index 1072c90..5e73b5b 100644 --- a/TaskB02/run.py +++ b/TaskB02/run.py @@ -20,17 +20,22 @@ for line in sys.stdin: state_move[(int(move.group(1)), move.group(3))] = (int(move.group(2)), 0) if succes: accept_states.append(int(line)) +print(state_move) -with open(sys.argv[1], 'r', encoding='utf-8') as f: +with open(sys.argv[1], 'r') as f: for word in f: + # starting with from 0 node because that is atandt standard current_state = 0 word = word.replace('\n', '') character_number = 0 - while character_number < len(word): + # 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)) if ((current_state, word[character_number]) in state_move): current_state = state_move[(current_state, word[character_number])][1] character_number += 1 - elif (current_state, '') in state_move): + # if there is epsilon program move to pointed node but didnt count epsilon as character + elif ((current_state, '') in state_move): current_state = state_move[(current_state, '')][0] else: current_state = -1 @@ -42,4 +47,4 @@ with open(sys.argv[1], 'r', encoding='utf-8') as f: if (current_state in accept_states): print("YES " + word) else: - print("NO" + word) + print("NO " + word)