update a1 notebook
This commit is contained in:
parent
3fe5f5a9e3
commit
20fdb9413d
@ -19,16 +19,36 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.482159200Z",
|
||||
"start_time": "2024-01-18T20:59:35.470889900Z"
|
||||
"end_time": "2024-01-18T21:45:24.278399500Z",
|
||||
"start_time": "2024-01-18T21:45:24.273024200Z"
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# util contains functions that make it easier to form strings \n",
|
||||
"# from languages, and give output that matches with expected \n",
|
||||
"# output for the homework, (replace empty string with epsilon)\n",
|
||||
"from util import *"
|
||||
"# Helper functions\n",
|
||||
"def get_all_strings_with_a_given_alphabet_and_length(_alphabet, _length):\n",
|
||||
"\t_strings = ['']\n",
|
||||
"\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": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.494611400Z",
|
||||
"start_time": "2024-01-18T20:59:35.477374Z"
|
||||
"end_time": "2024-01-18T21:45:24.284569900Z",
|
||||
"start_time": "2024-01-18T21:45:24.278399500Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -104,8 +124,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.536014100Z",
|
||||
"start_time": "2024-01-18T20:59:35.486263100Z"
|
||||
"end_time": "2024-01-18T21:45:24.288935300Z",
|
||||
"start_time": "2024-01-18T21:45:24.286415200Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -148,8 +168,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.536014100Z",
|
||||
"start_time": "2024-01-18T20:59:35.491094800Z"
|
||||
"end_time": "2024-01-18T21:45:24.296122800Z",
|
||||
"start_time": "2024-01-18T21:45:24.289936100Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -190,8 +210,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.539017300Z",
|
||||
"start_time": "2024-01-18T20:59:35.497609900Z"
|
||||
"end_time": "2024-01-18T21:45:24.298113500Z",
|
||||
"start_time": "2024-01-18T21:45:24.293966900Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -241,8 +261,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.581083800Z",
|
||||
"start_time": "2024-01-18T20:59:35.542564Z"
|
||||
"end_time": "2024-01-18T21:45:24.340947500Z",
|
||||
"start_time": "2024-01-18T21:45:24.299113600Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -282,8 +302,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.594528300Z",
|
||||
"start_time": "2024-01-18T20:59:35.585083400Z"
|
||||
"end_time": "2024-01-18T21:45:24.341947200Z",
|
||||
"start_time": "2024-01-18T21:45:24.303632300Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -331,8 +351,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.649706300Z",
|
||||
"start_time": "2024-01-18T20:59:35.597530600Z"
|
||||
"end_time": "2024-01-18T21:45:24.341947200Z",
|
||||
"start_time": "2024-01-18T21:45:24.307343300Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -392,8 +412,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.650706300Z",
|
||||
"start_time": "2024-01-18T20:59:35.603524100Z"
|
||||
"end_time": "2024-01-18T21:45:24.342947100Z",
|
||||
"start_time": "2024-01-18T21:45:24.314341500Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -461,8 +481,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.652706Z",
|
||||
"start_time": "2024-01-18T20:59:35.612375700Z"
|
||||
"end_time": "2024-01-18T21:45:24.342947100Z",
|
||||
"start_time": "2024-01-18T21:45:24.317844500Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
@ -511,8 +531,8 @@
|
||||
"metadata": {
|
||||
"collapsed": false,
|
||||
"ExecuteTime": {
|
||||
"end_time": "2024-01-18T20:59:35.691666Z",
|
||||
"start_time": "2024-01-18T20:59:35.656707400Z"
|
||||
"end_time": "2024-01-18T21:45:24.342947100Z",
|
||||
"start_time": "2024-01-18T21:45:24.323363100Z"
|
||||
}
|
||||
},
|
||||
"outputs": [
|
||||
|
Loading…
Reference in New Issue
Block a user