Skip to content

Commit b2cf32a

Browse files
committed
Adding new LLM solution
1 parent 32f1fcd commit b2cf32a

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

soln/chap07.ipynb

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -78267,7 +78267,13 @@
7826778267
"protracted\n",
7826878268
"protracting\n",
7826978269
"protractor\n",
78270-
"protractors\n",
78270+
"protractors\n"
78271+
]
78272+
},
78273+
{
78274+
"name": "stdout",
78275+
"output_type": "stream",
78276+
"text": [
7827178277
"protracts\n",
7827278278
"protrude\n",
7827378279
"protruded\n",
@@ -115774,6 +115780,7 @@
115774115780
"source": [
115775115781
"available = 'ACDLORT'\n",
115776115782
"required = 'R'\n",
115783+
"\n",
115777115784
"total = 0\n",
115778115785
"\n",
115779115786
"file_object = open('words.txt')\n",
@@ -115945,38 +115952,33 @@
115945115952
" >>> uses_all('apple', 'api')\n",
115946115953
" False\n",
115947115954
" \"\"\"\n",
115948-
" return not uses_any(letters, word)\n"
115955+
" return not uses_any(letters, word)"
115949115956
]
115950115957
},
115951115958
{
115952115959
"cell_type": "code",
115953115960
"execution_count": 71,
115961+
"id": "a3ea747d",
115962+
"metadata": {},
115963+
"outputs": [],
115964+
"source": [
115965+
"# Here's what I got from ChatGPT 4o December 26, 2024\n",
115966+
"# It's correct, but it makes multiple calls to uses_any \n",
115967+
"\n",
115968+
"def uses_all(s1, s2):\n",
115969+
" \"\"\"Checks if all characters in s2 are in s1, allowing repeats.\"\"\"\n",
115970+
" for char in s2:\n",
115971+
" if not uses_any(s1, char):\n",
115972+
" return False\n",
115973+
" return True\n"
115974+
]
115975+
},
115976+
{
115977+
"cell_type": "code",
115978+
"execution_count": 72,
115954115979
"id": "6980de57",
115955115980
"metadata": {},
115956-
"outputs": [
115957-
{
115958-
"name": "stdout",
115959-
"output_type": "stream",
115960-
"text": [
115961-
"**********************************************************************\n",
115962-
"File \"__main__\", line 11, in uses_all\n",
115963-
"Failed example:\n",
115964-
" uses_all('banana', 'ban')\n",
115965-
"Expected:\n",
115966-
" True\n",
115967-
"Got:\n",
115968-
" False\n",
115969-
"**********************************************************************\n",
115970-
"File \"__main__\", line 13, in uses_all\n",
115971-
"Failed example:\n",
115972-
" uses_all('ratatat', 'rat')\n",
115973-
"Expected:\n",
115974-
" True\n",
115975-
"Got:\n",
115976-
" False\n"
115977-
]
115978-
}
115979-
],
115981+
"outputs": [],
115980115982
"source": [
115981115983
"# Solution\n",
115982115984
"\n",

0 commit comments

Comments
 (0)