This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
on: [push, pull_request] | |
jobs: | |
cd: | |
concurrency: ci-${{ github.ref }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dfa import * | |
def scan_input_file(input_file_name): | |
" A function that scans the input file line by line and returns a DFA object based on what's scanned " | |
input_file = open(input_file_name, 'r') # open the input file | |
# read the 1st line and turn it to an integer | |
num_of_states = int(input_file.readline()) | |
print('Number of states: ', num_of_states) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DFA: | |
def __init__(self, states, alphabet, transition_function, start_state, end_states): | |
" DFA class constructor " | |
self.states = states | |
self.alphabet = alphabet | |
self.transition_function = transition_function | |
self.start_state = start_state | |
self.end_states = end_states | |
self.current_state = start_state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 | |
0 1 | |
0 | |
0 1 | |
0 1 1 | |
0 0 0 | |
1 1 2 | |
1 0 0 | |
2 1 2 | |
2 0 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dfa import * | |
from scan_input_file import * | |
dfa = scan_input_file("dfa.txt") | |
given_word = None | |
while given_word != '-1': | |
given_word = input('Type a word (-1 to exit): ') |