update a1 notebook

This commit is contained in:
Isaac Shoebottom 2024-01-18 17:48:05 -04:00
parent 3fe5f5a9e3
commit 20fdb9413d

View File

@ -19,16 +19,36 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.482159200Z", "end_time": "2024-01-18T21:45:24.278399500Z",
"start_time": "2024-01-18T20:59:35.470889900Z" "start_time": "2024-01-18T21:45:24.273024200Z"
} }
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# util contains functions that make it easier to form strings \n", "# Helper functions\n",
"# from languages, and give output that matches with expected \n", "def get_all_strings_with_a_given_alphabet_and_length(_alphabet, _length):\n",
"# output for the homework, (replace empty string with epsilon)\n", "\t_strings = ['']\n",
"from util import *" "\tfor itr in range(_length):\n",
"\t\t_string = [s + c for s in _strings for c in _alphabet]\n",
"\t\t_strings += _string\n",
"\n",
"\t# Remove duplicates (set() isn't as nice as it doesn't preserve order, at least for verification purposes)\n",
"\t_strings = list(dict.fromkeys(_strings))\n",
"\treturn _strings\n",
"\n",
"\n",
"def replace_empty_string_with_symbol(_strings):\n",
"\tsymbol = 'ε'\n",
"\tfor itr in range(len(_strings)):\n",
"\t\tif _strings[itr] == '':\n",
"\t\t\t_strings[itr] = symbol\n",
"\treturn _strings\n",
"\n",
"\n",
"def print_strings(_strings):\n",
"\t_strings = replace_empty_string_with_symbol(_strings)\n",
"\t# print(len(strings))\n",
"\tprint(_strings)"
] ]
}, },
{ {
@ -59,8 +79,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.494611400Z", "end_time": "2024-01-18T21:45:24.284569900Z",
"start_time": "2024-01-18T20:59:35.477374Z" "start_time": "2024-01-18T21:45:24.278399500Z"
} }
}, },
"outputs": [ "outputs": [
@ -104,8 +124,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.536014100Z", "end_time": "2024-01-18T21:45:24.288935300Z",
"start_time": "2024-01-18T20:59:35.486263100Z" "start_time": "2024-01-18T21:45:24.286415200Z"
} }
}, },
"outputs": [ "outputs": [
@ -148,8 +168,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.536014100Z", "end_time": "2024-01-18T21:45:24.296122800Z",
"start_time": "2024-01-18T20:59:35.491094800Z" "start_time": "2024-01-18T21:45:24.289936100Z"
} }
}, },
"outputs": [ "outputs": [
@ -190,8 +210,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.539017300Z", "end_time": "2024-01-18T21:45:24.298113500Z",
"start_time": "2024-01-18T20:59:35.497609900Z" "start_time": "2024-01-18T21:45:24.293966900Z"
} }
}, },
"outputs": [ "outputs": [
@ -241,8 +261,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.581083800Z", "end_time": "2024-01-18T21:45:24.340947500Z",
"start_time": "2024-01-18T20:59:35.542564Z" "start_time": "2024-01-18T21:45:24.299113600Z"
} }
}, },
"outputs": [ "outputs": [
@ -282,8 +302,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.594528300Z", "end_time": "2024-01-18T21:45:24.341947200Z",
"start_time": "2024-01-18T20:59:35.585083400Z" "start_time": "2024-01-18T21:45:24.303632300Z"
} }
}, },
"outputs": [ "outputs": [
@ -331,8 +351,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.649706300Z", "end_time": "2024-01-18T21:45:24.341947200Z",
"start_time": "2024-01-18T20:59:35.597530600Z" "start_time": "2024-01-18T21:45:24.307343300Z"
} }
}, },
"outputs": [ "outputs": [
@ -392,8 +412,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.650706300Z", "end_time": "2024-01-18T21:45:24.342947100Z",
"start_time": "2024-01-18T20:59:35.603524100Z" "start_time": "2024-01-18T21:45:24.314341500Z"
} }
}, },
"outputs": [ "outputs": [
@ -461,8 +481,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.652706Z", "end_time": "2024-01-18T21:45:24.342947100Z",
"start_time": "2024-01-18T20:59:35.612375700Z" "start_time": "2024-01-18T21:45:24.317844500Z"
} }
}, },
"outputs": [ "outputs": [
@ -511,8 +531,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2024-01-18T20:59:35.691666Z", "end_time": "2024-01-18T21:45:24.342947100Z",
"start_time": "2024-01-18T20:59:35.656707400Z" "start_time": "2024-01-18T21:45:24.323363100Z"
} }
}, },
"outputs": [ "outputs": [