{ "cells": [ { "cell_type": "markdown", "id": "95a637f8", "metadata": {}, "source": [ "Adapted from Prompt-aided Language Models [PAL](https://arxiv.org/pdf/2211.10435.pdf)." ] }, { "cell_type": "code", "execution_count": 1, "id": "3eefe2ae", "metadata": { "execution": { "iopub.execute_input": "2023-02-27T14:15:43.541342Z", "iopub.status.busy": "2023-02-27T14:15:43.541045Z", "iopub.status.idle": "2023-02-27T14:15:43.740615Z", "shell.execute_reply": "2023-02-27T14:15:43.739910Z" }, "lines_to_next_cell": 1 }, "outputs": [], "source": [ "import minichain" ] }, { "cell_type": "markdown", "id": "1932de81", "metadata": {}, "source": [ "PAL Prompt" ] }, { "cell_type": "code", "execution_count": 2, "id": "8b0f3ba4", "metadata": { "execution": { "iopub.execute_input": "2023-02-27T14:15:43.745885Z", "iopub.status.busy": "2023-02-27T14:15:43.744171Z", "iopub.status.idle": "2023-02-27T14:15:43.749926Z", "shell.execute_reply": "2023-02-27T14:15:43.749298Z" }, "lines_to_next_cell": 1 }, "outputs": [], "source": [ "class PalPrompt(minichain.TemplatePrompt):\n", " template_file = \"pal.pmpt.tpl\"" ] }, { "cell_type": "markdown", "id": "5e6b0f1e", "metadata": {}, "source": [ "Prompt to run and print python code." ] }, { "cell_type": "code", "execution_count": 3, "id": "5f5fea2c", "metadata": { "execution": { "iopub.execute_input": "2023-02-27T14:15:43.754328Z", "iopub.status.busy": "2023-02-27T14:15:43.753171Z", "iopub.status.idle": "2023-02-27T14:15:43.758857Z", "shell.execute_reply": "2023-02-27T14:15:43.758175Z" }, "lines_to_next_cell": 1 }, "outputs": [], "source": [ "class PyPrompt(minichain.Prompt):\n", " def prompt(self, inp):\n", " return inp + \"\\nprint(solution())\"\n", "\n", " def parse(self, response, inp):\n", " return int(response)" ] }, { "cell_type": "markdown", "id": "b494356e", "metadata": {}, "source": [ "Chain the prompts." ] }, { "cell_type": "code", "execution_count": 4, "id": "d6e170f7", "metadata": { "execution": { "iopub.execute_input": "2023-02-27T14:15:43.763969Z", "iopub.status.busy": "2023-02-27T14:15:43.762806Z", "iopub.status.idle": "2023-02-27T14:15:54.833413Z", "shell.execute_reply": "2023-02-27T14:15:54.832851Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "9\n" ] } ], "source": [ "with minichain.start_chain(\"pal\") as backend:\n", " question = \"Melanie is a door-to-door saleswoman. She sold a third of her ' \\\n", " 'vacuum cleaners at the green house, 2 more to the red house, and half of ' \\\n", " 'what was left at the orange house. If Melanie has 5 vacuum cleaners left, ' \\\n", " 'how many did she start with?'\"\n", " prompt = PalPrompt(backend.OpenAI()).chain(PyPrompt(backend.Python()))\n", " result = prompt({\"question\": question})\n", " print(result)" ] }, { "cell_type": "markdown", "id": "4a631744", "metadata": {}, "source": [ "View prompt examples." ] }, { "cell_type": "code", "execution_count": 5, "id": "729a67c3", "metadata": { "execution": { "iopub.execute_input": "2023-02-27T14:15:54.835748Z", "iopub.status.busy": "2023-02-27T14:15:54.835484Z", "iopub.status.idle": "2023-02-27T14:15:54.882169Z", "shell.execute_reply": "2023-02-27T14:15:54.881546Z" }, "tags": [ "hide_inp" ] }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "\n", "

PalPrompt

\n", "\n", "
\n", "
Input:
\n", "
\n", "
{'question': 'Joe has 10 cars and Bobby has 12. How many do they have together?'}\n",
       "
\n", "\n", "\n", "
\n", "\n", "
Full Prompt:
\n", "
\n", "
\n", " Prompt\n", "

Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?

# solution in Python:


def solution():
\"\"\"Olivia has $23. She bought five bagels for $3 each. How much money does she have left?\"\"\"
money_initial = 23
bagels = 5
bagel_cost = 3
money_spent = bagels * bagel_cost
money_left = money_initial - money_spent
result = money_left
return result





Q: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?

# solution in Python:


def solution():
\"\"\"Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?\"\"\"
golf_balls_initial = 58
golf_balls_lost_tuesday = 23
golf_balls_lost_wednesday = 2
golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday
result = golf_balls_left
return result





Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?

# solution in Python:


def solution():
\"\"\"There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?\"\"\"
computers_initial = 9
computers_per_day = 5
num_days = 4 # 4 days between monday and thursday
computers_added = computers_per_day * num_days
computers_total = computers_initial + computers_added
result = computers_total
return result





Q: Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?

# solution in Python:


def solution():
\"\"\"Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?\"\"\"
toys_initial = 5
mom_toys = 2
dad_toys = 2
total_received = mom_toys + dad_toys
total_toys = toys_initial + total_received
result = total_toys
return result





Q: Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?

# solution in Python:


def solution():
\"\"\"Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?\"\"\"
jason_lollipops_initial = 20
jason_lollipops_after = 12
denny_lollipops = jason_lollipops_initial - jason_lollipops_after
result = denny_lollipops
return result





Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?

# solution in Python:


def solution():
\"\"\"Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?\"\"\"
leah_chocolates = 32
sister_chocolates = 42
total_chocolates = leah_chocolates + sister_chocolates
chocolates_eaten = 35
chocolates_left = total_chocolates - chocolates_eaten
result = chocolates_left
return result





Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?

# solution in Python:


def solution():
\"\"\"If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?\"\"\"
cars_initial = 3
cars_arrived = 2
total_cars = cars_initial + cars_arrived
result = total_cars
return result





Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?

# solution in Python:


def solution():
\"\"\"There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?\"\"\"
trees_initial = 15
trees_after = 21
trees_added = trees_after - trees_initial
result = trees_added
return result





Q:

Joe has 10 cars and Bobby has 12. How many do they have together?


# solution in Python:

\n", "
\n", "
\n", "\n", "
Response:
\n", "
\n", " def solution():
\treturn 10 + 12\n", "
\n", "\n", "
Value:
\n", "
\n", "
def solution():\n",
       "\treturn 10 + 12\n",
       "
\n", "\n", "
\n", "
\n" ], "text/plain": [ "HTML(html='\\n\\n
\\n\\n

PalPrompt

\\n\\n
\\n
Input:
\\n
\\n
{'question': 'Joe has 10 cars and Bobby has 12. How many do they have together?'}\\n
\\n\\n\\n
\\n\\n
Full Prompt:
\\n
\\n
\\n Prompt\\n

Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?

# solution in Python:


def solution():
\"\"\"Olivia has $23. She bought five bagels for $3 each. How much money does she have left?\"\"\"
money_initial = 23
bagels = 5
bagel_cost = 3
money_spent = bagels * bagel_cost
money_left = money_initial - money_spent
result = money_left
return result





Q: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?

# solution in Python:


def solution():
\"\"\"Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?\"\"\"
golf_balls_initial = 58
golf_balls_lost_tuesday = 23
golf_balls_lost_wednesday = 2
golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday
result = golf_balls_left
return result





Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?

# solution in Python:


def solution():
\"\"\"There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?\"\"\"
computers_initial = 9
computers_per_day = 5
num_days = 4 # 4 days between monday and thursday
computers_added = computers_per_day * num_days
computers_total = computers_initial + computers_added
result = computers_total
return result





Q: Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?

# solution in Python:


def solution():
\"\"\"Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?\"\"\"
toys_initial = 5
mom_toys = 2
dad_toys = 2
total_received = mom_toys + dad_toys
total_toys = toys_initial + total_received
result = total_toys
return result





Q: Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?

# solution in Python:


def solution():
\"\"\"Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?\"\"\"
jason_lollipops_initial = 20
jason_lollipops_after = 12
denny_lollipops = jason_lollipops_initial - jason_lollipops_after
result = denny_lollipops
return result





Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?

# solution in Python:


def solution():
\"\"\"Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?\"\"\"
leah_chocolates = 32
sister_chocolates = 42
total_chocolates = leah_chocolates + sister_chocolates
chocolates_eaten = 35
chocolates_left = total_chocolates - chocolates_eaten
result = chocolates_left
return result





Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?

# solution in Python:


def solution():
\"\"\"If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?\"\"\"
cars_initial = 3
cars_arrived = 2
total_cars = cars_initial + cars_arrived
result = total_cars
return result





Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?

# solution in Python:


def solution():
\"\"\"There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?\"\"\"
trees_initial = 15
trees_after = 21
trees_added = trees_after - trees_initial
result = trees_added
return result





Q:

Joe has 10 cars and Bobby has 12. How many do they have together?


# solution in Python:

\\n
\\n
\\n\\n
Response:
\\n
\\n def solution():
\\treturn 10 + 12\\n
\\n\\n
Value:
\\n
\\n
def solution():\\n\\treturn 10 + 12\\n
\\n\\n
\\n
\\n')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "PalPrompt().show(\n", " {\"question\": \"Joe has 10 cars and Bobby has 12. How many do they have together?\"},\n", " \"def solution():\\n\\treturn 10 + 12\",\n", ")" ] }, { "cell_type": "code", "execution_count": 6, "id": "616a782d", "metadata": { "execution": { "iopub.execute_input": "2023-02-27T14:15:54.884523Z", "iopub.status.busy": "2023-02-27T14:15:54.884246Z", "iopub.status.idle": "2023-02-27T14:15:54.889558Z", "shell.execute_reply": "2023-02-27T14:15:54.889097Z" }, "tags": [ "hide_inp" ] }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "
\n", "\n", "

PyPrompt

\n", "\n", "
\n", "
Input:
\n", "
\n", "
def solution():\n",
       "\treturn 10 + 12\n",
       "
\n", "\n", "\n", "
\n", "\n", "
Full Prompt:
\n", "
\n", "
\n", " Prompt\n", "

def solution():
\treturn 10 + 12
print(solution())

\n", "
\n", "
\n", "\n", "
Response:
\n", "
\n", " 22\n", "
\n", "\n", "
Value:
\n", "
\n", "
22\n",
       "
\n", "\n", "
\n", "
\n" ], "text/plain": [ "HTML(html='\\n\\n
\\n\\n

PyPrompt

\\n\\n
\\n
Input:
\\n
\\n
def solution():\\n\\treturn 10 + 12\\n
\\n\\n\\n
\\n\\n
Full Prompt:
\\n
\\n
\\n Prompt\\n

def solution():
\\treturn 10 + 12
print(solution())

\\n
\\n
\\n\\n
Response:
\\n
\\n 22\\n
\\n\\n
Value:
\\n
\\n
22\\n
\\n\\n
\\n
\\n')" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "PyPrompt().show(\"def solution():\\n\\treturn 10 + 12\", \"22\")" ] }, { "cell_type": "markdown", "id": "5aad5ea7", "metadata": {}, "source": [ "View the log." ] }, { "cell_type": "code", "execution_count": 7, "id": "a4fb48ac", "metadata": { "execution": { "iopub.execute_input": "2023-02-27T14:15:54.892000Z", "iopub.status.busy": "2023-02-27T14:15:54.891678Z", "iopub.status.idle": "2023-02-27T14:15:54.914877Z", "shell.execute_reply": "2023-02-27T14:15:54.914134Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[38;5;15m28b775fd-0862-4c8f-aada-b6158be3b664\u001b[1m\u001b[0m\n", "└── \u001b[38;5;5m\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:44Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m10.739s\u001b[2m\u001b[0m\n", " ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:44Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.003s\u001b[2m\u001b[0m\n", " │ ├── \u001b[38;5;4minput\u001b[0m: \u001b[0m\n", " │ │ └── \u001b[38;5;4mquestion\u001b[0m: Melanie is a door-to-door saleswoman. She sold a third of her ' 'vacuum cleaners at the green house, 2 more to the red house, and half of ' 'what was left at the orange house. If Melanie has 5 vacuum cleaners left, ' 'how many did she start with?'\u001b[0m\n", " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:44Z\u001b[2m\u001b[0m\n", " ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:44Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m10.736s\u001b[2m\u001b[0m\n", " │ ├── \u001b[38;5;4mprompt\u001b[0m: Q: Olivia has $23. She bought five bagels for $3 each. How much money does she have left?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Olivia has $23. She bought five bagels for $3 each. How much money does she have left?\"\"\"⏎\n", " │ │ money_initial = 23⏎\n", " │ │ bagels = 5⏎\n", " │ │ bagel_cost = 3⏎\n", " │ │ money_spent = bagels * bagel_cost⏎\n", " │ │ money_left = money_initial - money_spent⏎\n", " │ │ result = money_left⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Michael had 58 golf balls. On tuesday, he lost 23 golf balls. On wednesday, he lost 2 more. How many golf balls did he have at the end of wednesday?\"\"\"⏎\n", " │ │ golf_balls_initial = 58⏎\n", " │ │ golf_balls_lost_tuesday = 23⏎\n", " │ │ golf_balls_lost_wednesday = 2⏎\n", " │ │ golf_balls_left = golf_balls_initial - golf_balls_lost_tuesday - golf_balls_lost_wednesday⏎\n", " │ │ result = golf_balls_left⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"There were nine computers in the server room. Five more computers were installed each day, from monday to thursday. How many computers are now in the server room?\"\"\"⏎\n", " │ │ computers_initial = 9⏎\n", " │ │ computers_per_day = 5⏎\n", " │ │ num_days = 4 # 4 days between monday and thursday⏎\n", " │ │ computers_added = computers_per_day * num_days⏎\n", " │ │ computers_total = computers_initial + computers_added⏎\n", " │ │ result = computers_total⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Shawn has five toys. For Christmas, he got two toys each from his mom and dad. How many toys does he have now?\"\"\"⏎\n", " │ │ toys_initial = 5⏎\n", " │ │ mom_toys = 2⏎\n", " │ │ dad_toys = 2⏎\n", " │ │ total_received = mom_toys + dad_toys⏎\n", " │ │ total_toys = toys_initial + total_received⏎\n", " │ │ result = total_toys⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Jason had 20 lollipops. He gave Denny some lollipops. Now Jason has 12 lollipops. How many lollipops did Jason give to Denny?\"\"\"⏎\n", " │ │ jason_lollipops_initial = 20⏎\n", " │ │ jason_lollipops_after = 12⏎\n", " │ │ denny_lollipops = jason_lollipops_initial - jason_lollipops_after⏎\n", " │ │ result = denny_lollipops⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Leah had 32 chocolates and her sister had 42. If they ate 35, how many pieces do they have left in total?\"\"\"⏎\n", " │ │ leah_chocolates = 32⏎\n", " │ │ sister_chocolates = 42⏎\n", " │ │ total_chocolates = leah_chocolates + sister_chocolates⏎\n", " │ │ chocolates_eaten = 35⏎\n", " │ │ chocolates_left = total_chocolates - chocolates_eaten⏎\n", " │ │ result = chocolates_left⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"If there are 3 cars in the parking lot and 2 more cars arrive, how many cars are in the parking lot?\"\"\"⏎\n", " │ │ cars_initial = 3⏎\n", " │ │ cars_arrived = 2⏎\n", " │ │ total_cars = cars_initial + cars_arrived⏎\n", " │ │ result = total_cars⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done, there will be 21 trees. How many trees did the grove workers plant today?\"\"\"⏎\n", " │ │ trees_initial = 15⏎\n", " │ │ trees_after = 21⏎\n", " │ │ trees_added = trees_after - trees_initial⏎\n", " │ │ result = trees_added⏎\n", " │ │ return result⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ Q: Melanie is a door-to-door saleswoman. She sold a third of her ' 'vacuum cleaners at the green house, 2 more to the red house, and half of ' 'what was left at the orange house. If Melanie has 5 vacuum cleaners left, ' 'how many did she start with?'⏎\n", " │ │ ⏎\n", " │ │ # solution in Python:\u001b[0m\n", " │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", " ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n", " │ ├── \u001b[38;5;4mresult\u001b[0m: ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Melanie is a door-to-door saleswoman. She sold a third of her vacuum cleaners at the green house, 2 more to the red house, and half of what was left at the orange house. If Melanie has 5 vacuum cleaners left, how many did she start with?\"\"\"⏎\n", " │ │ vacuum_cleaners_left = 5⏎\n", " │ │ vacuum_cleaners_sold_green = vacuum_cleaners_left // 3⏎\n", " │ │ vacuum_cleaners_sold_red = 2⏎\n", " │ │ vacuum_cleaners_sold_orange = (vacuum_cleaners_left - vacuum_cleaners_sold_green - vacuum_cleaners_sold_red) // 2⏎\n", " │ │ vacuum_cleaners_initial = vacuum_cleaners_left + vacuum_cleaners_sold_green + vacuum_cleaners_sold_red + vacuum_cleaners_sold_orange⏎\n", " │ │ result = vacuum_cleaners_initial⏎\n", " │ │ return result\u001b[0m\n", " │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", " └── \u001b[38;5;5m\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", "\n", "\u001b[38;5;15mf2a0c10a-9d37-45b0-af51-bc18b0da6877\u001b[1m\u001b[0m\n", "└── \u001b[38;5;5m\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n", " ├── \u001b[38;5;5mInput Function\u001b[0m/2/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n", " │ ├── \u001b[38;5;4minput\u001b[0m: ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Melanie is a door-to-door saleswoman. She sold a third of her vacuum cleaners at the green house, 2 more to the red house, and half of what was left at the orange house. If Melanie has 5 vacuum cleaners left, how many did she start with?\"\"\"⏎\n", " │ │ vacuum_cleaners_left = 5⏎\n", " │ │ vacuum_cleaners_sold_green = vacuum_cleaners_left // 3⏎\n", " │ │ vacuum_cleaners_sold_red = 2⏎\n", " │ │ vacuum_cleaners_sold_orange = (vacuum_cleaners_left - vacuum_cleaners_sold_green - vacuum_cleaners_sold_red) // 2⏎\n", " │ │ vacuum_cleaners_initial = vacuum_cleaners_left + vacuum_cleaners_sold_green + vacuum_cleaners_sold_red + vacuum_cleaners_sold_orange⏎\n", " │ │ result = vacuum_cleaners_initial⏎\n", " │ │ return result\u001b[0m\n", " │ └── \u001b[38;5;5mInput Function\u001b[0m/2/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", " ├── \u001b[38;5;5mPrompted\u001b[0m/3/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n", " │ ├── \u001b[38;5;4mprompt\u001b[0m: ⏎\n", " │ │ ⏎\n", " │ │ ⏎\n", " │ │ def solution():⏎\n", " │ │ \"\"\"Melanie is a door-to-door saleswoman. She sold a third of her vacuum cleaners at the green house, 2 more to the red house, and half of what was left at the orange house. If Melanie has 5 vacuum cleaners left, how many did she start with?\"\"\"⏎\n", " │ │ vacuum_cleaners_left = 5⏎\n", " │ │ vacuum_cleaners_sold_green = vacuum_cleaners_left // 3⏎\n", " │ │ vacuum_cleaners_sold_red = 2⏎\n", " │ │ vacuum_cleaners_sold_orange = (vacuum_cleaners_left - vacuum_cleaners_sold_green - vacuum_cleaners_sold_red) // 2⏎\n", " │ │ vacuum_cleaners_initial = vacuum_cleaners_left + vacuum_cleaners_sold_green + vacuum_cleaners_sold_red + vacuum_cleaners_sold_orange⏎\n", " │ │ result = vacuum_cleaners_initial⏎\n", " │ │ return result⏎\n", " │ │ print(solution())\u001b[0m\n", " │ └── \u001b[38;5;5mPrompted\u001b[0m/3/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", " ├── \u001b[38;5;5mResult\u001b[0m/4/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m0.000s\u001b[2m\u001b[0m\n", " │ ├── \u001b[38;5;4mresult\u001b[0m: 9⏎\n", " │ │ \u001b[0m\n", " │ └── \u001b[38;5;5mResult\u001b[0m/4/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", " └── \u001b[38;5;5m\u001b[0m/5\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", "\n", "\u001b[38;5;15m18cad0c1-8de2-4459-af6c-fd8426cdacad\u001b[1m\u001b[0m\n", "└── \u001b[38;5;5mpal\u001b[0m/1\u001b[0m ⇒ \u001b[38;5;2mstarted\u001b[0m \u001b[38;5;15m2023-02-27 14:15:43Z\u001b[2m\u001b[0m ⧖ \u001b[38;5;4m11.063s\u001b[2m\u001b[0m\n", " └── \u001b[38;5;5mpal\u001b[0m/2\u001b[0m ⇒ \u001b[38;5;2msucceeded\u001b[0m \u001b[38;5;15m2023-02-27 14:15:54Z\u001b[2m\u001b[0m\n", "\n" ] } ], "source": [ "minichain.show_log(\"pal.log\")" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "tags,-all" }, "kernelspec": { "display_name": "minichain", "language": "python", "name": "minichain" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.6" } }, "nbformat": 4, "nbformat_minor": 5 }