From d4f41fbd4418c7460be1c15a38cfc858757635ad Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Fri, 26 Jan 2024 18:17:03 -0400 Subject: [PATCH] Add a3 skeleton --- Assignment 3.ipynb | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Assignment 3.ipynb diff --git a/Assignment 3.ipynb b/Assignment 3.ipynb new file mode 100644 index 0000000..ac56172 --- /dev/null +++ b/Assignment 3.ipynb @@ -0,0 +1,51 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "initial_id", + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "from automata.fa.dfa import DFA\n", + "\n", + "# DFA which matches all binary strings ending in an odd number of '1's\n", + "my_dfa = DFA(\n", + "\tstates={'q0', 'q1', 'q2'},\n", + "\tinput_symbols={'0', '1'},\n", + "\ttransitions={\n", + "\t\t'q0': {'0': 'q0', '1': 'q1'},\n", + "\t\t'q1': {'0': 'q0', '1': 'q2'},\n", + "\t\t'q2': {'0': 'q2', '1': 'q1'}\n", + "\t},\n", + "\tinitial_state='q0',\n", + "\tfinal_states={'q1'}\n", + ")\n", + "my_dfa.show_diagram()" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}